﻿using System;
using System.Data; // CommandType.StoredProcedure;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services; // WebService Class;
using System.Data.SqlClient; // SQL Commands;

namespace WebServiceApplication
{
    /// <summary>
    /// This webservice accesses the database over the x.jcmr.biz web host. It uses methods to push and pull information from the database.
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class WebService : System.Web.Services.WebService
    {
        /* DATABASE SPECIFIC METHODS */
        /* ============================================================================================== */
        /// <summary>
        /// STRICTLY FOR TESTING PURPOSES. THIS METHOD WILL RESET THE DATABASE TO THE DEFAULT VALUES. 
        /// USE AT YOUR OWN DISCRETION.
        /// </summary>
        /// <returns>void</returns>
        [WebMethod]
        public void resetDatabaseToDefault()
        {
            try
            {
                // Execute the stored procedure and return a dataset.
                executeProcedure("resetDatabasetoDefault");
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
            }
        }

        /// <summary>
        /// This method is used to delete all of tickets from the database that have been corrupted by 
        /// delete statements.
        /// </summary>
        /// <returns>void</returns>
        [WebMethod]
        public void deleteCorruptTickets()
        {
            try
            {
                // Execute the stored procedure and return a dataset.
                executeProcedure("deleteCorruptTickets");
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
            }
        }

        /// <summary>
        /// This method is used to return all of tickets from the database that have been corrupted by 
        /// delete statements.
        /// </summary>
        /// <returns>List&lt;_Ticket&gt;</returns>
        [WebMethod]
        public List<_Ticket> getCorruptTickets()
        {
            try
            {
                // Execute the stored procedure and return a dataset.
                DataConversion DC = new DataConversion();
                return DC.ConvertDataSetTo_TicketList(executeProcedure("getCorruptTickets"));
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// STRICTLY FOR TESTING PURPOSES. THIS METHOD WILL REMOVE ALL VALUES FROM THE DATABASE. 
        /// USE AT YOUR OWN DISCRETION.
        /// </summary>
        /// <returns>void</returns>
        [WebMethod]
        public void removeValuesFromDatabase()
        {
            try
            {
                // Execute the stored procedure and return a dataset.
                executeProcedure("clearAllTableValues");
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
            }
        }

        /// <summary>
        /// "Flushes" the database of Guest Accounts. This method removes all Guest Accounts from the 
        /// database.
        /// It deletes the information from the Users table, CreditCard table, and nulls the ID in the 
        /// transactions table.
        /// </summary>
        /// <returns>void</returns>
        [WebMethod]
        public void flushGuestAccounts()
        {
            try
            {
                // Execute the stored procedure and return a dataset.
                executeProcedure("flushGuestAccounts");
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was an issue with the stored procedure.
                Console.WriteLine(nullReferenceException.Message);
            }
        }


        /* SESSION METHODS */
        /* ============================================================================================== */
        /// <summary>
        /// Inserts the session variable into the database associated with the current user.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="sessionID"></param>
        /// <returns>void</returns>
        [WebMethod]
        public void insertSession(string userName, string sessionID)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@userName", SqlDbType.VarChar);
                parameter1.Value = userName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@sessionID", SqlDbType.VarChar);
                parameter2.Value = sessionID;
                parameterList.Add(parameter2);

                // Execute the stored procedure and return a dataset.
                // If the dataset returns a value (the logged in user) return true, otherwise invalid 
                // credentials.
                executeProcedure("insertSession", parameterList);
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
            }
            catch (NullReferenceException nullReferenceException)
            {
                // The database returned no values.
                Console.WriteLine(nullReferenceException.Message);
            }
        }

        /// <summary>
        /// Inserts the session variable into the database associated with the current administrator.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="sessionID"></param>
        /// <returns>void</returns>
        [WebMethod]
        public void insertAdminSession(string userName, string sessionID)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@userName", SqlDbType.VarChar);
                parameter1.Value = userName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@sessionID", SqlDbType.VarChar);
                parameter2.Value = sessionID;
                parameterList.Add(parameter2);

                // Execute the stored procedure and return a dataset.
                // If the dataset returns a value (the logged in user) return true, otherwise invalid 
                // credentials.
                executeProcedure("insertAdminSession", parameterList);
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
            }
            catch (NullReferenceException nullReferenceException)
            {
                // The database returned no values.
                Console.WriteLine(nullReferenceException.Message);
            }
        }

        /// <summary>
        /// Gets the session variable from the database associated with the current user.
        /// </summary>
        /// <param name="userName"></param>
        /// <returns>string</returns>
        [WebMethod]
        public string getSession(string userName)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@userName", SqlDbType.VarChar);
                parameter1.Value = userName;
                parameterList.Add(parameter1);

                // Execute the stored procedure and return a dataset.
                // If the dataset returns a value (the logged in user) return true, otherwise invalid 
                // credentials.
                DataConversion DC = new DataConversion();
                return DC.ConvertDataSetTo_SessionString(executeProcedure("getSession", parameterList));
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // The database returned no values.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Gets the session variable from the database associated with the current administrator.
        /// </summary>
        /// <param name="userName"></param>
        /// <returns>string</returns>
        [WebMethod]
        public string getAdminSession(string userName)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@userName", SqlDbType.VarChar);
                parameter1.Value = userName;
                parameterList.Add(parameter1);

                // Execute the stored procedure and return a dataset.
                // If the dataset returns a value (the logged in user) return true, otherwise invalid 
                // credentials.
                DataConversion DC = new DataConversion();
                return DC.ConvertDataSetTo_SessionString(executeProcedure("getAdminSession", parameterList));
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // The database returned no values.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Deletes the session variable from the database associated with the current user.
        /// </summary>
        /// <param name="sessionID"></param>
        /// <returns>void</returns>
        [WebMethod]
        public void deleteSession(string sessionID)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter2 = new SqlParameter("@sessionID", SqlDbType.VarChar);
                parameter2.Value = sessionID;
                parameterList.Add(parameter2);

                // Execute the stored procedure and return a dataset.
                // If the dataset returns a value (the logged in user) return true, otherwise invalid 
                // credentials.
                executeProcedure("deleteSession", parameterList);
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
            }
            catch (NullReferenceException nullReferenceException)
            {
                // The database returned no values.
                Console.WriteLine(nullReferenceException.Message);
            }
        }


        /* USER METHODS */
        /* ============================================================================================== */
        /// <summary>
        /// Returns an int stating whether the user has successfully logged in.
        /// 0 returns successful login.
        /// 1 returns failed login.
        /// 2 returns SqlException. There was a database error.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int loginAsUser(string userName, string password)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@userName", SqlDbType.VarChar);
                parameter1.Value = userName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@password", SqlDbType.VarChar);
                parameter2.Value = password;
                parameterList.Add(parameter2);

                // Execute the stored procedure and return a dataset.
                // If the dataset returns a value (the logged in user) return true, otherwise invalid 
                // credentials.
                if (executeProcedure("UserLogin", parameterList).Tables[0].Rows.Count != 0) return 0;
                else return 1;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // The database returned no values.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
        }

        /// <summary>
        /// Returns a _User object from the specified userName.
        /// </summary>
        /// <param name="userName"></param>
        /// <returns>_User</returns>
        [WebMethod]
        public _User getSearchedUser(string userName)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@userName", SqlDbType.VarChar);
                parameter1.Value = userName;
                parameterList.Add(parameter1);

                // Execute the stored procedure and return a dataset.
                // If the dataset returns a value (the logged in user) return true, otherwise invalid 
                // credentials.
                DataConversion DC = new DataConversion();
                return DC.ConvertDataSetTo_User(executeProcedure("getUser", parameterList));
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns a List&lt;_CreditCard&gt; object from the database corresponding to the username.
        /// </summary>
        /// <param name="userName"></param>
        /// <returns>List&lt;_CreditCard&gt;</returns>
        [WebMethod]
        public List<_CreditCard> getCreditCardsFromUser(string userName)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@userName", SqlDbType.VarChar);
                parameter1.Value = userName;
                parameterList.Add(parameter1);

                // Execute the stored procedure to return a list of _CreditCard dataset objects.
                DataConversion DC = new DataConversion();
                return DC.ConvertDataSetTo_CreditCardList(
                    executeProcedure("getCreditCardsFromUser", parameterList));
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns a list of all recorded users.
        /// </summary>
        /// <returns>List&lt;_User&gt;</returns>
        [WebMethod]
        public List<_User> getUsers()
        {
            try
            {
                // Execute the stored procedure and return a dataset.
                DataConversion DC = new DataConversion();
                return DC.ConvertDataSetTo_UserList(executeProcedure("getUserList"));
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Inserts a new user into the database.
        /// 0 returns successful insert.
        /// 1 returns failed insert.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The username and/or email are already being used.
        /// </summary>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="email"></param>
        /// <param name="newsLetter"></param>
        /// <param name="membershipDate"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="age"></param>
        /// <param name="memberStatus"></param>
        /// <param name="address"></param>
        /// <param name="address2"></param>
        /// <param name="city"></param>
        /// <param name="state"></param>
        /// <param name="zip"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int insertUser(string firstName, string lastName, string email, bool newsLetter, 
            DateTime membershipDate, string userName, string password, int age, bool memberStatus, 
            bool studentStatus, string address, string address2, string city, string state, string zip)
        {
            try
            {
                // Verify the username and email are not already used before continuing any further.
                // If they are taken, throw an Exception stating they are unavailable for use.
                int count = 0;
                foreach (int x in ValidateUsernameAndEmail(email, userName))
                {
                    count++;
                    // Checks the first boolean value (email). If it's true, the email address is already 
                    // taken.
                    if (x == 0 && count == 1)
                        throw new Exception("Email address already in use. Please try another email " + 
                            "address.");

                    // Checks the second boolean value (username). If it's true, the username is already 
                    // taken.
                    if (x == 0 && count == 2)
                        throw new Exception("Username already in use. Please use a different Username.");

                    if (x == 2 && count == 1 || x == 2 && count == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@firstName", SqlDbType.VarChar);
                if (firstName.Length > 20)
                    throw new ArgumentException("First name must be 20 characters or less.");
                parameter1.Value = firstName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@lastName", SqlDbType.VarChar);
                if (lastName.Length > 20)
                    throw new ArgumentException("Last name must be 20 characters or less.");
                parameter2.Value = lastName;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@email", SqlDbType.VarChar);
                if (email.Length > 50)
                    throw new ArgumentException("Email must be 50 characters or less.");
                parameter3.Value = email;
                parameterList.Add(parameter3);

                SqlParameter parameter4 = new SqlParameter("@newsLetter", SqlDbType.Bit);
                parameter4.Value = newsLetter;
                parameterList.Add(parameter4);

                SqlParameter parameter5 = new SqlParameter("@membershipDate", SqlDbType.DateTime);
                parameter5.Value = membershipDate;
                parameterList.Add(parameter5);

                SqlParameter parameter6 = new SqlParameter("@userName", SqlDbType.VarChar);
                if (userName.Length > 20)
                    throw new ArgumentException("Username must be 20 characters or less.");
                parameter6.Value = userName;
                parameterList.Add(parameter6);

                SqlParameter parameter7 = new SqlParameter("@password", SqlDbType.VarChar);
                if (password.Length > 20)
                    throw new ArgumentException("Password must be 20 characters or less.");
                parameter7.Value = password;
                parameterList.Add(parameter7);

                SqlParameter parameter8 = new SqlParameter("@age", SqlDbType.Int);
                parameter8.Value = age;
                parameterList.Add(parameter8);

                SqlParameter parameter9 = new SqlParameter("@memberStatus", SqlDbType.Bit);
                parameter9.Value = memberStatus;
                parameterList.Add(parameter9);

                SqlParameter parameter10 = new SqlParameter("@address", SqlDbType.VarChar);
                if (address.Length > 50)
                    throw new ArgumentException("Address must be 50 characters or less.");
                parameter10.Value = address;
                parameterList.Add(parameter10);

                SqlParameter parameter11 = new SqlParameter("@address2", SqlDbType.VarChar);
                if (address2.Length > 50)
                    throw new ArgumentException("Address2 must be 50 characters or less.");
                parameter11.Value = address2;
                parameterList.Add(parameter11);

                SqlParameter parameter12 = new SqlParameter("@city", SqlDbType.VarChar);
                if (city.Length > 20)
                    throw new ArgumentException("City must be 20 characters or less.");
                parameter12.Value = city;
                parameterList.Add(parameter12);

                SqlParameter parameter13 = new SqlParameter("@state", SqlDbType.Char);
                if (state.Length != 2)
                    throw new ArgumentException("State must be exactly 2 characters.");
                parameter13.Value = state;
                parameterList.Add(parameter13);

                SqlParameter parameter14 = new SqlParameter("@zip", SqlDbType.Char);
                if (zip.Length > 5)
                    throw new ArgumentException("Zip must be 5 or less characters.");
                parameter14.Value = zip;
                parameterList.Add(parameter14);

                SqlParameter parameter15 = new SqlParameter("@studentStatus", SqlDbType.Bit);
                parameter15.Value = studentStatus;
                parameterList.Add(parameter15);

                // Execute the stored procedure and insert the new value into the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("addUser", parameterList);

                // Successful insert.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Modifies a user from the database.
        /// 0 returns successful update.
        /// 1 returns failed update.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The username and/or email are already being used.
        /// </summary>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="email"></param>
        /// <param name="newsLetter"></param>
        /// <param name="userName"></param>
        /// <param name="newUserName"></param>
        /// <param name="newPassword"></param>
        /// <param name="age"></param>
        /// <param name="memberStatus"></param>
        /// <param name="address"></param>
        /// <param name="address2"></param>
        /// <param name="city"></param>
        /// <param name="state"></param>
        /// <param name="zip"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int updateUser(string firstName, string lastName, string email, bool newsLetter, 
            string userName, string newUserName, string newPassword, int age, bool memberStatus, 
            string address, string address2, string city, string state, string zip)
        {
            try
            {
                // Verify the username and email are currently used before continuing any further.
                // If they are not, throw an Exception stating they do not exist.

                int errorCode = ValidateUsername(userName);
                    if (errorCode == 1)
                        throw new Exception("UserName does not exist.");

                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");

                errorCode = ValidateUsername(newUserName);
                if (errorCode == 0)
                    throw new Exception("UserName already taken.");

                if (errorCode == 2)
                    throw new InvalidOperationException("There was a database error.");
                
                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@firstName", SqlDbType.VarChar);
                if (firstName.Length > 20)
                    throw new ArgumentException("First name must be 20 characters or less.");
                parameter1.Value = firstName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@lastName", SqlDbType.VarChar);
                if (lastName.Length > 20)
                    throw new ArgumentException("Last name must be 20 characters or less.");
                parameter2.Value = lastName;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@email", SqlDbType.VarChar);
                if (email.Length > 50)
                    throw new ArgumentException("Email must be 50 characters or less.");
                parameter3.Value = email;
                parameterList.Add(parameter3);

                SqlParameter parameter4 = new SqlParameter("@newsLetter", SqlDbType.Bit);
                parameter4.Value = newsLetter;
                parameterList.Add(parameter4);

                SqlParameter parameter6 = new SqlParameter("@userName", SqlDbType.VarChar);
                if (userName.Length > 20)
                    throw new ArgumentException("Username must be 20 characters or less.");
                parameter6.Value = userName;
                parameterList.Add(parameter6);

                SqlParameter parameter16 = new SqlParameter("@newUserName", SqlDbType.VarChar);
                if (newUserName.Length > 20)
                    throw new ArgumentException("New username must be 20 characters or less.");
                parameter16.Value = newUserName;
                parameterList.Add(parameter16);

                SqlParameter parameter7 = new SqlParameter("@newPassword", SqlDbType.VarChar);
                if (newPassword.Length > 20)
                    throw new ArgumentException("New password must be 20 characters or less.");
                parameter7.Value = newPassword;
                parameterList.Add(parameter7);

                SqlParameter parameter8 = new SqlParameter("@age", SqlDbType.Int);
                parameter8.Value = age;
                parameterList.Add(parameter8);

                SqlParameter parameter9 = new SqlParameter("@memberStatus", SqlDbType.Bit);
                parameter9.Value = memberStatus;
                parameterList.Add(parameter9);

                SqlParameter parameter10 = new SqlParameter("@address", SqlDbType.VarChar);
                if (address.Length > 50)
                    throw new ArgumentException("Address must be 50 characters or less.");
                parameter10.Value = address;
                parameterList.Add(parameter10);

                SqlParameter parameter11 = new SqlParameter("@address2", SqlDbType.VarChar);
                if (address2.Length > 50)
                    throw new ArgumentException("Address2 must be 50 characters or less.");
                parameter11.Value = address2;
                parameterList.Add(parameter11);

                SqlParameter parameter12 = new SqlParameter("@city", SqlDbType.VarChar);
                if (city.Length > 20)
                    throw new ArgumentException("City must be 20 characters or less.");
                parameter12.Value = city;
                parameterList.Add(parameter12);

                SqlParameter parameter13 = new SqlParameter("@state", SqlDbType.Char);
                if (state.Length != 2)
                    throw new ArgumentException("State must be exactly 2 characters.");
                parameter13.Value = state;
                parameterList.Add(parameter13);

                SqlParameter parameter14 = new SqlParameter("@zip", SqlDbType.Char);
                if (zip.Length > 5)
                    throw new ArgumentException("Zip must be 5 or less characters.");
                parameter14.Value = zip;
                parameterList.Add(parameter14);

                // Execute the stored procedure and insert the new value into the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("editUser", parameterList);

                // Successful update.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Deletes a user from the database.
        /// 0 returns successful delete.
        /// 1 returns failed delete.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The username does not exist.
        /// </summary>
        /// <param name="userName"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int deleteUser(string userName)
        {
            try
            {
                // Verify the username exists before continuing any further.
                // If it is not taken, throw an Exception stating the user does not exist.

                int errorCode = ValidateUsername(userName);
                    // Checks the first boolean value (email). If it's true, the email address is already 
                    // taken.
                    if (errorCode == 1)
                        throw new Exception("User account does not exist.");

                    // Checks the second boolean value (username). If it's true, the username is already 
                    // taken.
                    if (errorCode == 2)
                        throw new Exception("There was a database error.");


                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter6 = new SqlParameter("@userName", SqlDbType.VarChar);
                if (userName.Length > 20)
                    throw new ArgumentException("Username must be 20 characters or less.");
                parameter6.Value = userName;
                parameterList.Add(parameter6);

                // Execute the stored procedure and insert the new value into the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("deleteUser", parameterList);

                // Successful delete.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }


        /* GUEST METHODS */
        /* ============================================================================================== */
        /// <summary>
        /// Inserts a new guest into the database.
        /// 0 returns successful insert.
        /// 1 returns failed insert.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The email is already being used.
        /// </summary>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="email"></param>
        /// <param name="age"></param>
        /// <param name="address"></param>
        /// <param name="address2"></param>
        /// <param name="city"></param>
        /// <param name="state"></param>
        /// <param name="zip"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int insertGuest(string firstName, string lastName, string email, int age, string address, 
            string address2, string city, string state, string zip)
        {
            try
            {
                // Verify the email is not already used before continuing any further.
                // If it is taken, throw an Exception stating it is unavailable for use.
                int errorCode = ValidateEmail(email);
                // Checks the first boolean value (email). If it's true, the email address is already taken.
                if (errorCode == 0)
                    throw new Exception("Email address already in use. Please try another email address.");

                if (errorCode == 2)
                    throw new InvalidOperationException("There was a database error.");

                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@firstName", SqlDbType.VarChar);
                if (firstName.Length > 20)
                    throw new ArgumentException("First name must be 20 characters or less.");
                parameter1.Value = firstName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@lastName", SqlDbType.VarChar);
                if (lastName.Length > 20)
                    throw new ArgumentException("Last name must be 20 characters or less.");
                parameter2.Value = lastName;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@email", SqlDbType.VarChar);
                if (email.Length > 50)
                    throw new ArgumentException("Email must be 50 characters or less.");
                parameter3.Value = email;
                parameterList.Add(parameter3);

                SqlParameter parameter4 = new SqlParameter("@age", SqlDbType.Int);
                parameter4.Value = age;
                parameterList.Add(parameter4);

                SqlParameter parameter5 = new SqlParameter("@address", SqlDbType.VarChar);
                if (address.Length > 50)
                    throw new ArgumentException("Address must be 50 characters or less.");
                parameter5.Value = address;
                parameterList.Add(parameter5);

                SqlParameter parameter6 = new SqlParameter("@address2", SqlDbType.VarChar);
                if (address2.Length > 50)
                    throw new ArgumentException("Address2 must be 50 characters or less.");
                parameter6.Value = address2;
                parameterList.Add(parameter6);

                SqlParameter parameter7 = new SqlParameter("@city", SqlDbType.VarChar);
                if (city.Length > 20)
                    throw new ArgumentException("City must be 20 characters or less.");
                parameter7.Value = city;
                parameterList.Add(parameter7);

                SqlParameter parameter8 = new SqlParameter("@state", SqlDbType.Char);
                if (state.Length != 2)
                    throw new ArgumentException("State must be exactly 2 characters.");
                parameter8.Value = state;
                parameterList.Add(parameter8);

                SqlParameter parameter9 = new SqlParameter("@zip", SqlDbType.Char);
                if (zip.Length > 5)
                    throw new ArgumentException("Zip must be 5 or less characters.");
                parameter9.Value = zip;
                parameterList.Add(parameter9);

                // Execute the stored procedure and insert the new value into the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("addGuest", parameterList);

                // Successful insert.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }


        /* ADMINISTRATOR METHODS */
        /* ============================================================================================== */
        /// <summary>
        /// Returns an int stating whether the administrator has successfully logged in.
        /// 0 returns successful login.
        /// 1 returns failed login.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns NullReferenceException. There was no table in the procedure.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int loginAsAdministrator(string userName, string password)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@username", SqlDbType.VarChar);
                parameter1.Value = userName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@password", SqlDbType.VarChar);
                parameter2.Value = password;
                parameterList.Add(parameter2);

                // Execute the stored procedure and return a dataset.
                // If the dataset returns a value (the logged in user) return true, otherwise invalid 
                // credentials.
                if (executeProcedure("AdminLogin", parameterList).Tables[0].Rows.Count != 0) return 0;
                else return 1;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 3;
            }
        }

        /// <summary>
        /// Returns an _Administrator object from the specified userName.
        /// </summary>
        /// <param name="userName"></param>
        /// <returns>_Administrator</returns>
        [WebMethod]
        public _Administrator getSearchedAdministrator(string userName)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@userName", SqlDbType.VarChar);
                parameter1.Value = userName;
                parameterList.Add(parameter1);

                // Execute the stored procedure and return a dataset.
                DataConversion DC = new DataConversion();
                return DC.ConvertDataSetTo_Administrator(executeProcedure("getAdmin", parameterList));
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Inserts a new administrator into the database. NOTE: The user must be created first.
        /// 0 returns successful insert.
        /// 1 returns failed insert.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The username is already being used and/or the administrator already exists.
        /// </summary>
        /// <param name="userName"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int insertAdministrator(string userName)
        {
            try
            {
                // Verify the username is created.
                if (ValidateUsername(userName) == 1)
                    // User is not created and must be.
                    throw new Exception("Username does not exist and must be created first.");

                // Verify the username is not a guest account.
                if (ValidateGuest(userName) == 0)
                    throw new Exception("An account cannot be a guest account.");

                // Verify the administrator does not already exist.
                if (ValidateAdministrator(userName) == 0)
                    throw new Exception("The administrator account already exists.");

                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                List<SqlParameter> parameterList = new List<SqlParameter>();

                SqlParameter parameter1 = new SqlParameter("@userName", SqlDbType.VarChar);
                if (userName.Length > 20)
                    throw new ArgumentException("Username must be 20 characters or less.");
                parameter1.Value = userName;
                parameterList.Add(parameter1);

                // Execute the stored procedure and insert the new value into the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("addAdmin", parameterList);

                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Deletes an administrator from the database.
        /// 0 returns successful delete.
        /// 1 returns failed delete.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The username does not exist.
        /// </summary>
        /// <param name="userName"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int deleteAdministrator(string userName)
        {
            try
            {
                // Verify the username is created.
                if (ValidateUsername(userName) == 1)
                    // User is not created and must be.
                    throw new Exception("Username does not exist and must be created first.");

                // Verify the username is not a guest account.
                if (ValidateGuest(userName) == 0)
                    throw new Exception("An account cannot be a guest account.");

                // Verify the administrator does exist.
                if (ValidateAdministrator(userName) == 1)
                    throw new Exception("The administrator account does not exist.");

                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                List<SqlParameter> parameterList = new List<SqlParameter>();

                SqlParameter parameter1 = new SqlParameter("@userName", SqlDbType.VarChar);
                if (userName.Length > 20)
                    throw new ArgumentException("Username must be 20 characters or less.");
                parameter1.Value = userName;
                parameterList.Add(parameter1);

                // Execute the stored procedure and insert the new value into the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("deleteAdmin", parameterList);

                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }


        /* EVENT METHODS */
        /* ============================================================================================== */
        /// <summary>
        /// Returns the top _OpenEvent object from the search results based on the search string.
        /// </summary>
        /// <param name="eventName"></param>
        /// <returns>_OpenEvent</returns>
        [WebMethod]
        public _OpenEvent getSearchedEvent(string eventName)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                // Execute the stored procedure and return a dataset.
                DataConversion DC = new DataConversion();
                return DC.ConvertDataSetTo_OpenEvent(executeProcedure("getEvent", parameterList));
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Inserts a new event into the database.
        /// 0 returns successful insert.
        /// 1 returns failed insert.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The transaction already exists.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="eventAvailable"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int insertEvent(string eventName, bool eventAvailable)
        {
            try
            {
                // Verify the event name is not already used before continuing any further.
                // If it is taken, throw an Exception stating the transaction already exists.
                int errorCode = ValidateEvent(eventName);
                {
                    // The event name already exists.
                    if (errorCode == 0)
                        throw new Exception("Event already exists.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                List<SqlParameter> parameterList = new List<SqlParameter>();
                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                if (eventName.Length > 50)
                    throw new ArgumentException("Event name must be 50 characters or less.");
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@eventAvailable", SqlDbType.Bit);
                parameter2.Value = eventAvailable;
                parameterList.Add(parameter2);

                // Execute the stored procedure and insert the new value into the database.
                // This procedure adds the transaction to the Transactions table.
                executeProcedure("addEvent", parameterList);

                // Successful insert.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Modifies an event from the database.
        /// 0 returns successful update.
        /// 1 returns failed update.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The event does not exist.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="newEventName"></param>
        /// <param name="eventAvailable"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int updateEvent(string eventName, string newEventName, bool eventAvailable)
        {
            try
            {
                // Verify the event name exists used before continuing any further.
                // If it does not, throw an Exception stating the event does not exist.
                int errorCode = ValidateEvent(eventName);
                {
                    // The event name already exists.
                    if (errorCode == 1)
                        throw new Exception("Event does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                errorCode = ValidateEvent(newEventName);
                {
                    if (errorCode == 0)
                        throw new Exception("New event name already exists.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                List<SqlParameter> parameterList = new List<SqlParameter>();
                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                if (eventName.Length > 50)
                    throw new ArgumentException("Event name must be 50 characters or less.");
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                SqlParameter parameter3 = new SqlParameter("@newEventName", SqlDbType.VarChar);
                if (newEventName.Length > 50)
                    throw new ArgumentException("New event name must be 50 characters or less.");
                parameter3.Value = newEventName;
                parameterList.Add(parameter3);

                SqlParameter parameter2 = new SqlParameter("@eventAvailable", SqlDbType.Bit);
                parameter2.Value = eventAvailable;
                parameterList.Add(parameter2);

                // Execute the stored procedure and insert the new value into the database.
                executeProcedure("editEvent", parameterList);

                // Successful update.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Modifies an event from the database and DOES NOT validate the new event name (used in case name 
        /// is already validated and causes issues).
        /// 0 returns successful update.
        /// 1 returns failed update.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The event does not exist.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="newEventName"></param>
        /// <param name="eventAvailable"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int updateEventWithoutValidation(string eventName, string newEventName, bool eventAvailable)
        {
            try
            {
                // Verify the event name exists used before continuing any further.
                // If it does not, throw an Exception stating the event does not exist.
                int errorCode = ValidateEvent(eventName);
                {
                    // The event name already exists.
                    if (errorCode == 1)
                        throw new Exception("Event does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                List<SqlParameter> parameterList = new List<SqlParameter>();
                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                if (eventName.Length > 50)
                    throw new ArgumentException("Event name must be 50 characters or less.");
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                SqlParameter parameter3 = new SqlParameter("@newEventName", SqlDbType.VarChar);
                if (newEventName.Length > 50)
                    throw new ArgumentException("New event name must be 50 characters or less.");
                parameter3.Value = newEventName;
                parameterList.Add(parameter3);

                SqlParameter parameter2 = new SqlParameter("@eventAvailable", SqlDbType.Bit);
                parameter2.Value = eventAvailable;
                parameterList.Add(parameter2);

                // Execute the stored procedure and insert the new value into the database.
                executeProcedure("editEvent", parameterList);

                // Successful update.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Delete an event into the database.
        /// 0 returns successful delete.
        /// 1 returns failed delete.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The event is not existent.
        /// </summary>
        /// <param name="eventName"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int deleteEvent(string eventName)
        {
            try
            {
                // Verify the event name exists before continuing any further.
                // If it is not taken, throw an Exception stating the event does not exists.
                int errorCode = ValidateEvent(eventName);
                {
                    // The event name does not exist.
                    if (errorCode == 1)
                        throw new Exception("Event does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                List<SqlParameter> parameterList = new List<SqlParameter>();
                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                if (eventName.Length > 50)
                    throw new ArgumentException("Event name must be 50 characters or less.");
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                // Execute the stored procedure and insert the new value into the database.
                // This procedure adds the transaction to the Transactions table.
                DataSet data = executeProcedure("deleteEvent", parameterList);

                if (data == null)
                    return 2;

                // Successful insert.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Returns a list of all _OpenEvent objects from the database based on the search string.
        /// </summary>
        /// <param name="eventName"></param>
        /// <returns>List&lt;_OpenEvent&gt;</returns>
        [WebMethod]
        public List<_OpenEvent> getAllSearchedEvents(string eventName)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                // Execute the stored procedure and return a dataset.
                DataConversion DC = new DataConversion();
                return DC.ConvertDataSetTo_OpenEventList(executeProcedure("getEvent", parameterList));
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns all _OpenEvent objects from the database.
        /// </summary>
        /// <returns>List&lt;_OpenEvent&gt;</returns>
        [WebMethod]
        public List<_OpenEvent> getAllEvents()
        {
            try
            {
                // Execute the stored procedure and return a dataset.
                DataConversion DC = new DataConversion();
                return DC.ConvertDataSetTo_OpenEventList(executeProcedure("getAllEvents"));
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }


        /* TICKET METHODS */
        /* ============================================================================================== */
        /// <summary>
        /// Returns a _Ticket object from the database.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="venueName"></param>
        /// <param name="sectionName"></param>
        /// <param name="row"></param>
        /// <param name="seat"></param>
        /// <returns>_Ticket</returns>
        [WebMethod]
        public _Ticket getTicket(string eventName, string venueName, string sectionName, string row, 
            string seat)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter2.Value = venueName;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                parameter3.Value = sectionName;
                parameterList.Add(parameter3);

                SqlParameter parameter4 = new SqlParameter("@row", SqlDbType.VarChar);
                parameter4.Value = row;
                parameterList.Add(parameter4);

                SqlParameter parameter5 = new SqlParameter("@seat", SqlDbType.VarChar);
                parameter5.Value = seat;
                parameterList.Add(parameter5);
                
                // Execute the next stored procedure to return a dataset of related ticket objects.
                DataConversion DC = new DataConversion();
                _Ticket ticket = DC.ConvertDataSetTo_Ticket(
                    executeProcedure("getSingleTicket", parameterList));

                // Execute the next stored procedure to return a dataset of sections and fill the ticket 
                // values.
                parameterList.Clear();
                parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                parameter2 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter2.Value = venueName;
                parameterList.Add(parameter2);

                parameter3 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                parameter3.Value = sectionName;
                parameterList.Add(parameter3);

                _Section section = DC.ConvertDataSetTo_Section(
                    executeProcedure("getSection", parameterList));
                ticket.basePrice = section.basePrice;
                ticket.multiplierFrequency = section.multiplierFrequency;
                ticket.priceMultiplier = section.priceMultiplier;
                ticket.sectionAvailable = section.sectionAvailable;
                ticket.sectionName = section.sectionName;

                // Execute the next stored procedure to return a dataset of venues and fill the ticket 
                // values.
                parameterList.Clear();
                parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                parameter2 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter2.Value = venueName;
                parameterList.Add(parameter2);
                
                _Venue venue = DC.ConvertDataSetTo_Venue(executeProcedure("getVenue", parameterList));
                ticket.city = venue.city;
                ticket.dateEnd = venue.dateEnd;
                ticket.dateStart = venue.dateStart;
                ticket.state = venue.state;
                ticket.venueAvailable = venue.venueAvailable;
                ticket.venueName = venue.venueName;

                // Execute the next stored procedure to return a dataset of events and fill the ticket 
                // values.
                parameterList.Clear();
                parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                _OpenEvent openEvent = DC.ConvertDataSetTo_OpenEvent(
                    executeProcedure("getEvent", parameterList));
                ticket.eventAvailable = openEvent.eventAvailable;
                ticket.eventName = openEvent.eventName;

                return ticket;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns a list of all _Ticket objects from the database based on the eventName.
        /// </summary>
        /// <param name="eventName"></param>
        /// <returns>List&lt;_Ticket&gt;</returns>
        [WebMethod]
        public List<_Ticket> getTicketsFromEvent(string eventName)
        {
            try
            {
                List<_Ticket> masterTicketList = new List<_Ticket>();

                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                DataConversion DC = new DataConversion();
                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);
                
                // Return all venues from the Event.
                // Iterate through the venues to find the sections.
                foreach (_Venue v in DC.ConvertDataSetTo_VenueList(
                    executeProcedure("getVenuesFromEvent", parameterList)))
                {
                    // Clear the old parameters and create new ones.
                    parameterList.Clear();
                    parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                    parameter1.Value = v.venueName;
                    parameterList.Add(parameter1);

                    SqlParameter parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                    parameter2.Value = eventName;
                    parameterList.Add(parameter2);

                    // Return all sections from the Events > Venue.
                    foreach (_Section s in DC.ConvertDataSetTo_SectionList(
                        executeProcedure("getSectionsInVenue", parameterList)))
                    {
                        // Clear the old parameters and create new ones.
                        parameterList.Clear();                        
                        parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                        parameter1.Value = v.venueName;
                        parameterList.Add(parameter1);

                        parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                        parameter2.Value = eventName;
                        parameterList.Add(parameter2);

                        SqlParameter parameter3 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                        parameter3.Value = s.sectionName;
                        parameterList.Add(parameter3);
                
                        // Return the ticket objects from the Events > Venue > Section.
                        foreach (_Ticket ticket in DC.ConvertDataSetTo_TicketList(
                            executeProcedure("getTicketsFromSection", parameterList)))
                        {
                            masterTicketList.Add(
                                fillTicketFromTables(ticket, eventName, v.venueName, s.sectionName));
                        }
                    }
                }
                return masterTicketList;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns a list of string objects from the database representing the available ticket types.
        /// </summary>
        /// <returns>List&lt;string&gt;</returns>
        [WebMethod]
        public List<string> getAllTicketTypes()
        {
            try
            {
                // Execute the stored procedure and return a dataset.
                DataConversion DC = new DataConversion();
                return DC.ConvertDataSetTo_stringList(executeProcedure("getAllTicketTypes"));
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns a list of _Ticket objects from the database representing the all of the purchased 
        /// tickets.
        /// </summary>
        /// <returns>List&lt;_Ticket&gt;</returns>
        [WebMethod]
        public List<_Ticket> getAllPurchasedTickets()
        {
            try
            {
                // Execute the stored procedure and return a dataset.
                DataConversion DC = new DataConversion();
                List<SqlParameter> parameterList = new List<SqlParameter>();

                List<_Ticket> list = DC.ConvertDataSetTo_TicketListWithValues(
                    executeProcedure("getAllPurchasedTickets"));
                foreach (_Ticket t in list)
                {
                    // Clear the old parameters and create new ones.
                    parameterList.Clear();
                    SqlParameter parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                    parameter1.Value = t.venueName;
                    parameterList.Add(parameter1);

                    SqlParameter parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                    parameter2.Value = t.eventName;
                    parameterList.Add(parameter2);

                    SqlParameter parameter3 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                    parameter3.Value = t.sectionName;
                    parameterList.Add(parameter3);

                    fillTicketFromTables(t, t.eventName, t.venueName, t.sectionName);
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns a List&lt;_Ticket&gt; object from the database associated with the confirmation number.
        /// </summary>
        /// <param name="confirmationNumber"></param>
        /// <returns>List&lt;_Ticket&gt;</returns>
        [WebMethod]
        public List<_Ticket> getTicketsFromTransaction(string confirmationNumber)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@confirmNum", SqlDbType.VarChar);
                parameter1.Value = confirmationNumber;
                parameterList.Add(parameter1);

                // Execute the next stored procedure to return a dataset of related ticket objects.
                // Add the ticket objects to the transaction.
                DataConversion DC = new DataConversion();

                List<_Ticket> list = DC.ConvertDataSetTo_TicketListWithValues(
                    executeProcedure("getTicketsFromTransaction", parameterList));
                foreach (_Ticket t in list)
                {
                    // Clear the old parameters and create new ones.
                    parameterList.Clear();
                    parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                    parameter1.Value = t.venueName;
                    parameterList.Add(parameter1);

                    SqlParameter parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                    parameter2.Value = t.eventName;
                    parameterList.Add(parameter2);

                    SqlParameter parameter3 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                    parameter3.Value = t.sectionName;
                    parameterList.Add(parameter3);

                    fillTicketFromTables(t, t.eventName, t.venueName, t.sectionName);
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns a list of _Ticket objects from the database based on the event and venue name.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="venueName"></param>
        /// <returns>List&lt;_Ticket&gt;</returns>
        [WebMethod]
        public List<_Ticket> getTicketsFromVenue(string eventName, string venueName)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter2.Value = venueName;
                parameterList.Add(parameter2);

                // Execute the next stored procedure to return a dataset of related ticket objects.
                DataConversion DC = new DataConversion();
                List<_Ticket> list = DC.ConvertDataSetTo_TicketListWithValues(
                    executeProcedure("getTicketsFromVenue", parameterList));
                foreach (_Ticket t in list)
                {
                    // Clear the old parameters and create new ones.
                    parameterList.Clear();
                    parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                    parameter1.Value = t.venueName;
                    parameterList.Add(parameter1);

                    parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                    parameter2.Value = t.eventName;
                    parameterList.Add(parameter2);

                    SqlParameter parameter3 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                    parameter3.Value = t.sectionName;
                    parameterList.Add(parameter3);

                    fillTicketFromTables(t, t.eventName, t.venueName, t.sectionName);
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns a list of _Ticket objects from the database based on the event, venue, and section name.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="venueName"></param>
        /// <param name="sectionName"></param>
        /// <returns>List&lt;_Ticket&gt;</returns>
        [WebMethod]
        public List<_Ticket> getTicketsFromSection(string eventName, string venueName, string sectionName)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter2.Value = venueName;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                parameter3.Value = sectionName;
                parameterList.Add(parameter3);

                // Execute the next stored procedure to return a dataset of related ticket objects.
                DataConversion DC = new DataConversion();
                List<_Ticket> list = DC.ConvertDataSetTo_TicketListWithValues(
                    executeProcedure("getTicketsFromSection", parameterList));
                foreach (_Ticket t in list)
                {
                    // Clear the old parameters and create new ones.
                    parameterList.Clear();
                    parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                    parameter1.Value = t.venueName;
                    parameterList.Add(parameter1);

                    parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                    parameter2.Value = t.eventName;
                    parameterList.Add(parameter2);

                    parameter3 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                    parameter3.Value = t.sectionName;
                    parameterList.Add(parameter3);

                    fillTicketFromTables(t, t.eventName, t.venueName, t.sectionName);
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Inserts a new ticket into the database.
        /// 0 returns successful insert.
        /// 1 returns failed insert.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The transaction already exists.
        /// </summary>
        /// <param name="className"></param>
        /// <param name="eventName"></param>
        /// <param name="venueName"></param>
        /// <param name="sectionName"></param>
        /// <param name="row"></param>
        /// <param name="seat"></param>
        /// <param name="price"></param>
        /// <param name="ticketAvailable"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int insertTicket(string className, string eventName, string venueName, string sectionName, 
            string row, string seat, decimal price, bool ticketAvailable)
        {
            try
            {
                // Verify the ticket does not already exist before continuing any further.
                // If it is taken, throw an Exception stating the ticket already exists.
                int errorCode = ValidateTicket(eventName, venueName, sectionName, row, seat);
                {
                    // The ticket already exists.
                    if (errorCode == 0)
                        throw new Exception("Ticket already exists.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                // Verify the event name is available before continuing any further.
                // If it is not available, throw an Exception stating the event needs to exists.
                errorCode = ValidateEvent(eventName);
                {
                    // The event name already exists.
                    if (errorCode == 1)
                        throw new Exception("Event does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                // Verify the venue name is available before continuing any further.
                // If it is not available, throw an Exception stating the venue needs to exists.
                errorCode = ValidateVenue(venueName, eventName);
                {
                    // The venue name does not exist.
                    if (errorCode == 1)
                        throw new Exception("Venue does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                // Verify the section name is available before continuing any further.
                // If it is not available, throw an Exception stating the section needs to exists.
                errorCode = ValidateSection(venueName, sectionName);
                {
                    // The section name does not exist.
                    if (errorCode == 1)
                        throw new Exception("Section does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                // Verify the class name is available before continuing any further.
                // If it is not available, throw an Exception stating the class name needs to exists.
                errorCode = ValidateTicketType(className);
                {
                    // The class name does not exist.
                    if (errorCode == 1)
                        throw new Exception("Ticket class does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                List<SqlParameter> parameterList = new List<SqlParameter>();
                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                SqlParameter parameter1 = new SqlParameter("@className", SqlDbType.VarChar);
                if (className.Length > 30)
                    throw new ArgumentException("Ticket class name must be 30 characters or less.");
                parameter1.Value = className;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                if (eventName.Length > 50)
                    throw new ArgumentException("Event name must be 50 characters or less.");
                parameter2.Value = eventName;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@venueName", SqlDbType.VarChar);
                if (venueName.Length > 50)
                    throw new ArgumentException("Venue name must be 50 characters or less.");
                parameter3.Value = venueName;
                parameterList.Add(parameter3);

                SqlParameter parameter4 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                if (sectionName.Length > 50)
                    throw new ArgumentException("Section name must be 50 characters or less.");
                parameter4.Value = sectionName;
                parameterList.Add(parameter4);

                SqlParameter parameter5 = new SqlParameter("@row", SqlDbType.VarChar);
                if (row.Length > 10)
                    throw new ArgumentException("Row must be 10 characters or less.");
                parameter5.Value = row;
                parameterList.Add(parameter5);

                SqlParameter parameter6 = new SqlParameter("@seat", SqlDbType.VarChar);
                if (seat.Length > 10)
                    throw new ArgumentException("Seat must be 10 characters or less.");
                parameter6.Value = seat;
                parameterList.Add(parameter6);

                SqlParameter parameter7 = new SqlParameter("@price", SqlDbType.Decimal);
                parameter7.Value = price;
                parameterList.Add(parameter7);

                SqlParameter parameter8 = new SqlParameter("@ticketAvailable", SqlDbType.Bit);
                parameter8.Value = ticketAvailable;
                parameterList.Add(parameter8);

                // Execute the stored procedure and insert the new value into the database.
                executeProcedure("addTicket", parameterList);

                // Successful insert.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Modifies a ticket from the database.
        /// 0 returns successful update.
        /// 1 returns failed update.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The ticket does not exist.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="venueName"></param>
        /// <param name="sectionName"></param>
        /// <param name="className"></param>
        /// <param name="row"></param>
        /// <param name="newRow"></param>
        /// <param name="seat"></param>
        /// <param name="newSeat"></param>
        /// <param name="price"></param>
        /// <param name="ticketAvailable"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int updateTicket(string eventName, string venueName, string sectionName, string className, 
            string row, string newRow, string seat, string newSeat, decimal price, bool ticketAvailable)
        {
            try
            {
                // Verify the ticket exists before continuing any further.
                // If it is does not, throw an Exception stating the ticket does not exist.
                int errorCode = ValidateTicket(eventName, venueName, sectionName, row, seat);
                {
                    // The ticket does not exist.
                    if (errorCode == 1)
                        throw new Exception("Ticket does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                errorCode = ValidateTicket(eventName, venueName, sectionName, newRow, newSeat);
                {
                    // The ticket already exists.
                    if (errorCode == 0)
                        throw new Exception("New ticket values already exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                // Verify the event name is available before continuing any further.
                // If it is not available, throw an Exception stating the event needs to exists.
                errorCode = ValidateEvent(eventName);
                {
                    // The event name already exists.
                    if (errorCode == 1)
                        throw new Exception("Event does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                // Verify the venue name is available before continuing any further.
                // If it is not available, throw an Exception stating the venue needs to exists.
                errorCode = ValidateVenue(venueName, eventName);
                {
                    // The venue name does not exist.
                    if (errorCode == 1)
                        throw new Exception("Venue does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                // Verify the section name is available before continuing any further.
                // If it is not available, throw an Exception stating the section needs to exists.
                errorCode = ValidateSection(venueName, sectionName);
                {
                    // The section name does not exist.
                    if (errorCode == 1)
                        throw new Exception("Section does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                // Verify the class name is available before continuing any further.
                // If it is not available, throw an Exception stating the class name needs to exists.
                errorCode = ValidateTicketType(className);
                {
                    // The class name does not exist.
                    if (errorCode == 1)
                        throw new Exception("Ticket class does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                List<SqlParameter> parameterList = new List<SqlParameter>();
                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                SqlParameter parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                if (eventName.Length > 50)
                    throw new ArgumentException("Event name must be 50 characters or less.");
                parameter2.Value = eventName;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@venueName", SqlDbType.VarChar);
                if (venueName.Length > 50)
                    throw new ArgumentException("Venue name must be 50 characters or less.");
                parameter3.Value = venueName;
                parameterList.Add(parameter3);

                SqlParameter parameter4 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                if (sectionName.Length > 50)
                    throw new ArgumentException("Section name must be 50 characters or less.");
                parameter4.Value = sectionName;
                parameterList.Add(parameter4);

                SqlParameter parameter1 = new SqlParameter("@className", SqlDbType.VarChar);
                if (className.Length > 30)
                    throw new ArgumentException("Ticket class name must be 30 characters or less.");
                parameter1.Value = className;
                parameterList.Add(parameter1);

                SqlParameter parameter5 = new SqlParameter("@row", SqlDbType.VarChar);
                if (row.Length > 10)
                    throw new ArgumentException("Row must be 10 characters or less.");
                parameter5.Value = row;
                parameterList.Add(parameter5);

                SqlParameter parameter9 = new SqlParameter("@newRow", SqlDbType.VarChar);
                if (newRow.Length > 10)
                    throw new ArgumentException("New row must be 10 characters or less.");
                parameter9.Value = newRow;
                parameterList.Add(parameter9);

                SqlParameter parameter6 = new SqlParameter("@seat", SqlDbType.VarChar);
                if (seat.Length > 10)
                    throw new ArgumentException("Seat must be 10 characters or less.");
                parameter6.Value = seat;
                parameterList.Add(parameter6);

                SqlParameter parameter10 = new SqlParameter("@newSeat", SqlDbType.VarChar);
                if (newSeat.Length > 10)
                    throw new ArgumentException("New seat must be 10 characters or less.");
                parameter10.Value = newSeat;
                parameterList.Add(parameter10);

                SqlParameter parameter7 = new SqlParameter("@price", SqlDbType.Decimal);
                parameter7.Value = price;
                parameterList.Add(parameter7);

                SqlParameter parameter8 = new SqlParameter("@ticketAvailable", SqlDbType.Bit);
                parameter8.Value = ticketAvailable;
                parameterList.Add(parameter8);

                // Execute the stored procedure and insert the new value into the database.
                executeProcedure("editTicket", parameterList);

                // Successful insert.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Deletes a ticket from the database.
        /// 0 returns successful insert.
        /// 1 returns failed insert.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The ticket does not exist.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="venueName"></param>
        /// <param name="sectionName"></param>
        /// <param name="row"></param>
        /// <param name="seat"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int deleteTicket(string eventName, string venueName, string sectionName, string row, 
            string seat)
        {
            try
            {
                // Verify the ticket does not already exist before continuing any further.
                // If it is taken, throw an Exception stating the ticket already exists.
                int errorCode = ValidateTicket(eventName, venueName, sectionName, row, seat);
                {
                    // The ticket does not exists
                    if (errorCode == 1)
                        throw new Exception("Ticket does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                List<SqlParameter> parameterList = new List<SqlParameter>();
                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                SqlParameter parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                if (eventName.Length > 50)
                    throw new ArgumentException("Event name must be 50 characters or less.");
                parameter2.Value = eventName;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@venueName", SqlDbType.VarChar);
                if (venueName.Length > 50)
                    throw new ArgumentException("Venue name must be 50 characters or less.");
                parameter3.Value = venueName;
                parameterList.Add(parameter3);

                SqlParameter parameter4 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                if (sectionName.Length > 50)
                    throw new ArgumentException("Section name must be 50 characters or less.");
                parameter4.Value = sectionName;
                parameterList.Add(parameter4);

                SqlParameter parameter5 = new SqlParameter("@row", SqlDbType.VarChar);
                if (row.Length > 10)
                    throw new ArgumentException("Row must be 10 characters or less.");
                parameter5.Value = row;
                parameterList.Add(parameter5);

                SqlParameter parameter6 = new SqlParameter("@seat", SqlDbType.VarChar);
                if (seat.Length > 10)
                    throw new ArgumentException("Seat must be 10 characters or less.");
                parameter6.Value = seat;
                parameterList.Add(parameter6);

                // Execute the stored procedure and insert the new value into the database.
                executeProcedure("deleteTicket", parameterList);

                // Successful delete.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Inserts a new ticket type into the database.
        /// 0 returns successful insert.
        /// 1 returns failed insert.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The transaction already exists.
        /// </summary>
        /// <param name="className"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int insertTicketType(string className)
        {
            try
            {
                // Verify the class name does not exist before continuing any further.
                // If it exists, throw an Exception stating the class name already exists.
                int errorCode = ValidateTicketType(className);
                {
                    // The class name already exists.
                    if (errorCode == 0)
                        throw new Exception("Ticket class already exists.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                List<SqlParameter> parameterList = new List<SqlParameter>();
                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                SqlParameter parameter1 = new SqlParameter("@className", SqlDbType.VarChar);
                if (className.Length > 30)
                    throw new ArgumentException("Ticket class name must be 30 characters or less.");
                parameter1.Value = className;
                parameterList.Add(parameter1);

                // Execute the stored procedure and insert the new value into the database.
                executeProcedure("addTicketType", parameterList);

                // Successful insert.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Modifies a ticket type from the database.
        /// 0 returns successful update.
        /// 1 returns failed update.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The ticket type does not exist.
        /// </summary>
        /// <param name="className"></param>
        /// <param name="newClassName"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int updateTicketType(string className, string newClassName)
        {
            try
            {
                // Verify the class name does not exist before continuing any further.
                // If it exists, throw an Exception stating the class name already exists.
                int errorCode = ValidateTicketType(className);
                {
                    // The class name does not exist.
                    if (errorCode == 1)
                        throw new Exception("Ticket class does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                errorCode = ValidateTicketType(newClassName);
                {
                    // The class name already exists.
                    if (errorCode == 0)
                        throw new Exception("New ticket class already exists.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                List<SqlParameter> parameterList = new List<SqlParameter>();
                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                SqlParameter parameter1 = new SqlParameter("@className", SqlDbType.VarChar);
                if (className.Length > 30)
                    throw new ArgumentException("Ticket class name must be 30 characters or less.");
                parameter1.Value = className;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@newClassName", SqlDbType.VarChar);
                if (newClassName.Length > 30)
                    throw new ArgumentException("New ticket class name must be 30 characters or less.");
                parameter2.Value = newClassName;
                parameterList.Add(parameter2);

                // Execute the stored procedure and insert the new value into the database.
                executeProcedure("editTicketType", parameterList);

                // Successful update.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Deletes a ticket type from the database.
        /// 0 returns successful delete.
        /// 1 returns failed delete.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The ticket type does not exist.
        /// </summary>
        /// <param name="className"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int deleteTicketType(string className)
        {
            try
            {
                // Verify the class name exists before continuing any further.
                // If it does not exist, throw an Exception stating the class name does not exist.
                int errorCode = ValidateTicketType(className);
                {
                    // The class name does not exist.
                    if (errorCode == 1)
                        throw new Exception("Ticket class does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                List<SqlParameter> parameterList = new List<SqlParameter>();
                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                SqlParameter parameter1 = new SqlParameter("@className", SqlDbType.VarChar);
                if (className.Length > 30)
                    throw new ArgumentException("Ticket class name must be 30 characters or less.");
                parameter1.Value = className;
                parameterList.Add(parameter1);

                // Execute the stored procedure and insert the new value into the database.
                executeProcedure("deleteTicketType", parameterList);

                // Successful insert.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }


        /* TRANSACTION METHODS */
        /* ============================================================================================== */
        /// <summary>
        /// Returns a _Transaction object from the database with the corresponding transaction owner.
        /// If the _User object in the _Transaction object is null. The account may have been flushed.
        /// </summary>
        /// <param name="confirmationNumber"></param>
        /// <returns>_Transaction</returns>
        [WebMethod]
        public _Transaction getTransaction(string confirmationNumber)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@confirmNum", SqlDbType.VarChar);
                parameter1.Value = confirmationNumber;
                parameterList.Add(parameter1);

                // Execute the stored procedure to return a _Transaction object.
                DataConversion DC = new DataConversion();
                _Transaction transaction = DC.ConvertDataSetTo_Transaction(
                    executeProcedure("getSingleTransaction", parameterList));

                // Execute the next stored procedure to return a dataset of related ticket objects.
                // Add the ticket objects to the transaction.
                List<_Ticket> list = DC.ConvertDataSetTo_TicketListWithValues(
                    executeProcedure("getTicketsFromTransaction", parameterList));
                foreach (_Ticket t in list)
                {
                    // Clear the old parameters and create new ones.
                    parameterList.Clear();
                    parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                    parameter1.Value = t.venueName;
                    parameterList.Add(parameter1);

                    SqlParameter parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                    parameter2.Value = t.eventName;
                    parameterList.Add(parameter2);

                    SqlParameter parameter3 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                    parameter3.Value = t.sectionName;
                    parameterList.Add(parameter3);

                    fillTicketFromTables(t, t.eventName, t.venueName, t.sectionName);
                }
                transaction.ticketList = list;

                // Execute the next stored procedure to return a dataset for the user object.
                // Add the user object to the transaction.
                // May return null due to flushed accounts.
                // Clear the old parameters and create new ones.
                parameterList.Clear();
                parameter1 = new SqlParameter("@confirmNum", SqlDbType.VarChar);
                parameter1.Value = confirmationNumber;
                parameterList.Add(parameter1);
                _User transactionOwner = DC.ConvertDataSetTo_User(
                    executeProcedure("getUserFromTransaction", parameterList));
                transaction.transactionOwner = transactionOwner;

                return transaction;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns a List&lt;_Transaction&gt; object from the database with the corresponding transaction 
        /// owner associated with the userName.
        /// If the _User object in the _Transaction object is null. The account may have been flushed.
        /// </summary>
        /// <param name="userName"></param>
        /// <returns>List&lt;_Transaction&gt;</returns>
        [WebMethod]
        public List<_Transaction> getTransactionsFromUser(string userName)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@userName", SqlDbType.VarChar);
                parameter1.Value = userName;
                parameterList.Add(parameter1);

                // Execute the stored procedure to return a _Transaction object.
                DataConversion DC = new DataConversion();
                List<_Transaction> list = DC.ConvertDataSetTo_TransactionList(
                    executeProcedure("getTransactionsFromUser", parameterList));

                foreach (_Transaction transaction in list)
                {
                    parameterList.Clear();
                    SqlParameter parameter2 = new SqlParameter("@confirmNum", SqlDbType.VarChar);
                    parameter2.Value = transaction.confirmationNum;
                    parameterList.Add(parameter2);

                    // Execute the next stored procedure to return a dataset of related ticket objects.
                    // Add the ticket objects to the transaction.
                    List<_Ticket> ticketList = DC.ConvertDataSetTo_TicketListWithValues(
                        executeProcedure("getTicketsFromTransaction", parameterList));
                    foreach (_Ticket t in ticketList)
                    {
                        // Clear the old parameters and create new ones.
                        parameterList.Clear();
                        parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                        parameter1.Value = t.venueName;
                        parameterList.Add(parameter1);

                        parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                        parameter2.Value = t.eventName;
                        parameterList.Add(parameter2);

                        SqlParameter parameter3 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                        parameter3.Value = t.sectionName;
                        parameterList.Add(parameter3);

                        fillTicketFromTables(t, t.eventName, t.venueName, t.sectionName);
                    }
                    transaction.ticketList = ticketList;

                    // Execute the next stored procedure to return a dataset for the user object.
                    // Add the user object to the transaction.
                    // May return null due to flushed accounts.
                    // Clear the old parameters and create new ones.
                    parameterList.Clear();
                    parameter1 = new SqlParameter("@confirmNum", SqlDbType.VarChar);
                    parameter1.Value = transaction.confirmationNum;
                    parameterList.Add(parameter1);
                    _User transactionOwner = DC.ConvertDataSetTo_User(
                        executeProcedure("getUserFromTransaction", parameterList));
                    transaction.transactionOwner = transactionOwner;
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }
        
        /// <summary>
        /// Returns a List&lt;_Transaction&gt; object from the database with the corresponding transaction 
        /// owner.
        /// If the _User object in the _Transaction object is null. The account may have been flushed.
        /// </summary>
        /// <returns>List&lt;_Transaction&gt;</returns>
        [WebMethod]
        public List<_Transaction> getAllTransactions()
        {
            try
            {
                // Execute the stored procedure to return a _Transaction object.
                DataConversion DC = new DataConversion();
                List<_Transaction> list = DC.ConvertDataSetTo_TransactionList(
                    executeProcedure("getAllTransactions"));

                List<SqlParameter> parameterList = new List<SqlParameter>();
                foreach (_Transaction transaction in list)
                {
                    parameterList.Clear();
                    SqlParameter parameter1 = new SqlParameter("@confirmNum", SqlDbType.VarChar);
                    parameter1.Value = transaction.confirmationNum;
                    parameterList.Add(parameter1);

                    // Execute the next stored procedure to return a dataset of related ticket objects.
                    // Add the ticket objects to the transaction.
                    List<_Ticket> ticketList = DC.ConvertDataSetTo_TicketListWithValues(
                        executeProcedure("getTicketsFromTransaction", parameterList));
                    foreach (_Ticket t in ticketList)
                    {
                        // Clear the old parameters and create new ones.
                        parameterList.Clear();
                        parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                        parameter1.Value = t.venueName;
                        parameterList.Add(parameter1);

                        SqlParameter parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                        parameter2.Value = t.eventName;
                        parameterList.Add(parameter2);

                        SqlParameter parameter3 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                        parameter3.Value = t.sectionName;
                        parameterList.Add(parameter3);

                        fillTicketFromTables(t, t.eventName, t.venueName, t.sectionName);
                    }
                    transaction.ticketList = ticketList;

                    // Execute the next stored procedure to return a dataset for the user object.
                    // Add the user object to the transaction.
                    // May return null due to flushed accounts.
                    // Clear the old parameters and create new ones.
                    parameterList.Clear();
                    parameter1 = new SqlParameter("@confirmNum", SqlDbType.VarChar);
                    parameter1.Value = transaction.confirmationNum;
                    parameterList.Add(parameter1);
                    _User transactionOwner = DC.ConvertDataSetTo_User(
                        executeProcedure("getUserFromTransaction", parameterList));
                    transaction.transactionOwner = transactionOwner;
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Deletes a transaction from the database.
        /// 0 returns successful delete.
        /// 1 returns failed delete.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The transaction does not exist.
        /// </summary>
        /// <param name="confirmationNumber"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int deleteTransaction(string confirmationNumber)
        {
            try
            {
                // Verify the confirmationNumber is already in the database before continuing any further.
                // If it is unavailable, throw an Exception stating the transaction does not exist.
                int errorCode = ValidateConfirmationNumber(confirmationNumber);
                {
                    // The confirmationNumber is unavailable.
                    if (errorCode == 1)
                        throw new Exception("Transaction does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }
                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter7 = new SqlParameter("@confirmNum", SqlDbType.VarChar);
                if (confirmationNumber.Length > 15)
                    throw new ArgumentException("Confirmation number must be 15 characters.");
                parameter7.Value = confirmationNumber;
                parameterList.Add(parameter7);

                // Execute the stored procedure and insert the new value into the database.
                // This procedure adds the transaction to the Transactions table.
                executeProcedure("deleteTransaction", parameterList);

                // Return the row count affected to determine if there was an error.
                // Successful insert.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Inserts a new transaction into the database.
        /// 0 returns successful insert.
        /// 1 returns failed insert.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The transaction already exists.
        /// </summary>
        /// <param name="confirmationNumber"></param>
        /// <param name="userName"></param>
        /// <param name="purchaseDate"></param>
        /// <param name="delivered"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int insertTransaction(string confirmationNumber, string userName, 
            List<_Ticket> purchasedTickets, DateTime purchaseDate, bool delivered)
        {
            try
            {
                // Verify the confirmationNumber is not already used before continuing any further.
                // If it is taken, throw an Exception stating the transaction already exists.
                int errorCode = ValidateConfirmationNumber(confirmationNumber);
                {
                    // The confirmationNumber is unavailable.
                    if (errorCode == 0)
                        throw new Exception("Transaction already exists.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                // Verify the userName is in the database.
                _User verifiedUser = getSearchedUser(userName);
                if (verifiedUser == null)
                    throw new Exception("There is no associated user with the transaction.");

                List<SqlParameter> parameterList = new List<SqlParameter>();

                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                SqlParameter parameter7 = new SqlParameter("@confirmNum", SqlDbType.VarChar);
                if (confirmationNumber.Length > 15)
                    throw new ArgumentException("Confirmation number must be 15 characters.");
                parameter7.Value = confirmationNumber;
                parameterList.Add(parameter7);

                SqlParameter parameter8 = new SqlParameter("@userName", SqlDbType.VarChar);
                if (userName.Length > 20)
                    throw new ArgumentException("Username must be 20 characters or less.");
                parameter8.Value = userName;
                parameterList.Add(parameter8);

                SqlParameter parameter9 = new SqlParameter("@purchaseDate", SqlDbType.DateTime);
                parameter9.Value = purchaseDate;
                parameterList.Add(parameter9);

                SqlParameter parameter10 = new SqlParameter("@delivered", SqlDbType.Bit);
                parameter10.Value = delivered;
                parameterList.Add(parameter10);

                // Execute the stored procedure and insert the new value into the database.
                // This procedure adds the transaction to the Transactions table.
                DataSet data2 = executeProcedure("addTransaction", parameterList);

                // Change ticket availability for all purchased tickets, then send them to the database.
                foreach (_Ticket t in purchasedTickets)
                {
                    // Clear the previous parameters, then create parameters for stored procedure.
                    // If the parameters do not meet database criteria, throw an ArgumentException.
                    parameterList.Clear();
                    SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                    parameter1.Value = t.eventName;
                    parameterList.Add(parameter1);

                    SqlParameter parameter2 = new SqlParameter("@venueName", SqlDbType.VarChar);
                    parameter2.Value = t.venueName;
                    parameterList.Add(parameter2);

                    SqlParameter parameter3 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                    parameter3.Value = t.sectionName;
                    parameterList.Add(parameter3);

                    SqlParameter parameter4 = new SqlParameter("@row", SqlDbType.VarChar);
                    parameter4.Value = t.row;
                    parameterList.Add(parameter4);

                    SqlParameter parameter5 = new SqlParameter("@seat", SqlDbType.VarChar);
                    parameter5.Value = t.seat;
                    parameterList.Add(parameter5);

                    SqlParameter parameter6 = new SqlParameter("@confirmNum", SqlDbType.VarChar);
                    parameter6.Value = confirmationNumber;
                    parameterList.Add(parameter6);

                    SqlParameter parameter11 = new SqlParameter("@ticketAvailable", SqlDbType.Bit);
                    parameter11.Value = false;
                    parameterList.Add(parameter11);

                    // Execute the stored procedure and insert the new value into the database.
                    // This procedure adds the tickets into the purchasedTickets table and updates the 
                    // ticket in the Tickets table.
                    executeProcedure("addPurchasedTickets", parameterList);
                }
                // Return the row count affected to determine if there was an error.
                // Successful insert.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Modifies a transaction from the database.
        /// 0 returns successful update.
        /// 1 returns failed update.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The transaction does not exist.
        /// </summary>
        /// <param name="confirmationNumber"></param>
        /// <param name="delivered"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int updateTransaction(string confirmationNumber, bool delivered)
        {
            try
            {
                // Verify the confirmationNumber exists before continuing any further.
                // If it does not, throw an Exception stating the transaction does not exist.
                int errorCode = ValidateConfirmationNumber(confirmationNumber);
                {
                    // The confirmationNumber is unavailable.
                    if (errorCode == 1)
                        throw new Exception("Transaction does not exist.");

                    // SQL Exception
                    if (errorCode == 2)
                        throw new InvalidOperationException("There was a database error.");
                }

                List<SqlParameter> parameterList = new List<SqlParameter>();

                // Create parameters for stored procedure. If the parameters do not meet database criteria,
                // throw an ArgumentException.
                SqlParameter parameter7 = new SqlParameter("@confirmNum", SqlDbType.VarChar);
                if (confirmationNumber.Length > 15)
                    throw new ArgumentException("Confirmation number must be 15 characters.");
                parameter7.Value = confirmationNumber;
                parameterList.Add(parameter7);

                SqlParameter parameter10 = new SqlParameter("@delivered", SqlDbType.Bit);
                parameter10.Value = delivered;
                parameterList.Add(parameter10);

                // Execute the stored procedure and insert the new value into the database.
                // This procedure adds the transaction to the Transactions table.
                DataSet data2 = executeProcedure("editTransaction", parameterList);

                // Return the row count affected to determine if there was an error.
                // Successful update.
                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // There was a database error when validating the username and email.
                Console.WriteLine(invalidOperationException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }


        /* VENUE METHODS */
        /* ============================================================================================== */
        /// <summary>
        /// Returns a venue based on the venue name.
        /// </summary>
        /// <param name="venueName"></param>
        /// <returns>_Venue</returns>
        [WebMethod]
        public _Venue getSearchedVenue(string eventName, string venueName)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter1.Value = venueName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter2.Value = eventName;
                parameterList.Add(parameter2);

                // Execute the stored procedure and return a dataset.
                DataConversion DC = new DataConversion();
                _Venue venue = DC.ConvertDataSetTo_Venue(executeProcedure("getVenue", parameterList));

                parameterList.Clear();
                parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                return fillVenueFromTables(venue, eventName);
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns a list of venue objects based on the event name.
        /// </summary>
        /// <param name="eventName"></param>
        /// <returns>List&lt;_Venue*gt;</returns>
        [WebMethod]
        public List<_Venue> getVenuesFromEvent(string eventName)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                // Execute the stored procedure and return a dataset.
                DataConversion DC = new DataConversion();
                List<_Venue> venueList = DC.ConvertDataSetTo_VenueList(
                    executeProcedure("getVenuesFromEvent", parameterList));

                foreach (_Venue v in venueList)
                {
                    fillVenueFromTables(v, eventName);
                }
                return venueList;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns a list of all recorded venues.
        /// </summary>
        /// <returns>List&lt;_Venue&gt;</returns>
        [WebMethod]
        public List<_Venue> getAllVenues()
        {
            try
            {
                // Execute the stored procedure and return a dataset.
                DataConversion DC = new DataConversion();
                List<_Venue> venueList = DC.ConvertDataSetTo_VenueListWithValues(
                    executeProcedure("getAllVenues"));

                foreach (_Venue v in venueList)
                {
                    fillVenueFromTables(v, v.eventName);
                }
                return venueList;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Inserts a new venue into the database.
        /// 0 returns successful insert.
        /// 1 returns failed insert.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The username is already being used and/or the administrator already exists.
        /// </summary>
        /// <param name="venueName"></param>
        /// <param name="dateStart"></param>
        /// <param name="dateEnd"></param>
        /// <param name="venueAvailable"></param>
        /// <param name="eventName"></param>
        /// <param name="city"></param>
        /// <param name="state"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int insertVenue(string venueName, DateTime dateStart, DateTime dateEnd, bool venueAvailable, 
            string eventName, string city, string state)
        {
            try
            {
                // Verify the Event actually exists.
                if (ValidateEvent(eventName) == 1)
                    throw new Exception("The Event does not exist.");

                // Verify the venue does not already exist.
                if (ValidateVenue(venueName, eventName) == 0)
                    throw new Exception("The venue already exists.");

                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                if (venueName.Length > 50)
                    throw new ArgumentException("Venue name must be 50 characters or less.");
                parameter1.Value = venueName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@dateStart", SqlDbType.VarChar);
                parameter2.Value = dateStart;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@dateEnd", SqlDbType.VarChar);
                parameter3.Value = dateEnd;
                parameterList.Add(parameter3);

                SqlParameter parameter4 = new SqlParameter("@venueAvailable", SqlDbType.Bit);
                parameter4.Value = venueAvailable;
                parameterList.Add(parameter4);

                SqlParameter parameter5 = new SqlParameter("@eventName", SqlDbType.VarChar);
                if (eventName.Length > 50)
                    throw new ArgumentException("Event name must be 50 characters or less.");
                parameter5.Value = eventName;
                parameterList.Add(parameter5);

                SqlParameter parameter6 = new SqlParameter("@city", SqlDbType.VarChar);
                if (city.Length > 20)
                    throw new ArgumentException("City must be 20 characters or less.");
                parameter6.Value = city;
                parameterList.Add(parameter6);

                SqlParameter parameter7 = new SqlParameter("@state", SqlDbType.Char);
                if (state.Length != 2)
                    throw new ArgumentException("State must be exactly 2 characters.");
                parameter7.Value = state;
                parameterList.Add(parameter7);

                // Execute the stored procedure and insert the new value into the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("addVenue", parameterList);

                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Modifies a venue from the database.
        /// 0 returns successful update.
        /// 1 returns failed update.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The venue does not exist.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="venueName"></param>
        /// <param name="newVenueName"></param>
        /// <param name="dateStart"></param>
        /// <param name="dateEnd"></param>
        /// <param name="venueAvailable"></param>
        /// <param name="city"></param>
        /// <param name="state"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int updateVenue(string eventName, string venueName, string newVenueName, DateTime dateStart, 
            DateTime dateEnd, bool venueAvailable, string city, string state)
        {
            try
            {
                // Verify the Event actually exists.
                if (ValidateEvent(eventName) == 1)
                    throw new Exception("The Event does not exist.");

                // Verify the venue actually exists.
                if (ValidateVenue(venueName, eventName) == 1)
                    throw new Exception("The venue does not exist.");

                // Verify the venue actually exists.
                if (ValidateVenue(newVenueName, eventName) == 0)
                    throw new Exception("The new venue already exists.");

                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                if (venueName.Length > 50)
                    throw new ArgumentException("Venue name must be 50 characters or less.");
                parameter1.Value = venueName;
                parameterList.Add(parameter1);

                SqlParameter parameter8 = new SqlParameter("@newVenueName", SqlDbType.VarChar);
                if (newVenueName.Length > 50)
                    throw new ArgumentException("New venue name must be 50 characters or less.");
                parameter8.Value = newVenueName;
                parameterList.Add(parameter8);

                SqlParameter parameter2 = new SqlParameter("@dateStart", SqlDbType.VarChar);
                parameter2.Value = dateStart;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@dateEnd", SqlDbType.VarChar);
                parameter3.Value = dateEnd;
                parameterList.Add(parameter3);

                SqlParameter parameter4 = new SqlParameter("@venueAvailable", SqlDbType.Bit);
                parameter4.Value = venueAvailable;
                parameterList.Add(parameter4);

                SqlParameter parameter5 = new SqlParameter("@eventName", SqlDbType.VarChar);
                if (eventName.Length > 50)
                    throw new ArgumentException("Event name must be 50 characters or less.");
                parameter5.Value = eventName;
                parameterList.Add(parameter5);

                SqlParameter parameter6 = new SqlParameter("@city", SqlDbType.VarChar);
                if (city.Length > 20)
                    throw new ArgumentException("City must be 20 characters or less.");
                parameter6.Value = city;
                parameterList.Add(parameter6);

                SqlParameter parameter7 = new SqlParameter("@state", SqlDbType.Char);
                if (state.Length != 2)
                    throw new ArgumentException("State must be exactly 2 characters.");
                parameter7.Value = state;
                parameterList.Add(parameter7);

                // Execute the stored procedure and insert the new value into the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("editVenue", parameterList);

                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Deletes a venue from the database.
        /// 0 returns successful delete.
        /// 1 returns failed delete.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The username is already being used and/or the administrator already exists.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="venueName"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int deleteVenue(string eventName, string venueName)
        {
            try
            {
                // Verify the Event actually exists.
                if (ValidateEvent(eventName) == 1)
                    throw new Exception("The Event does not exist.");

                // Verify the venue actually exists.
                if (ValidateVenue(venueName, eventName) == 1)
                    throw new Exception("The venue does not exist.");

                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                if (venueName.Length > 50)
                    throw new ArgumentException("Venue name must be 50 characters or less.");
                parameter1.Value = venueName;
                parameterList.Add(parameter1);

                SqlParameter parameter5 = new SqlParameter("@eventName", SqlDbType.VarChar);
                if (eventName.Length > 50)
                    throw new ArgumentException("Event name must be 50 characters or less.");
                parameter5.Value = eventName;
                parameterList.Add(parameter5);

                // Execute the stored procedure and delete the value from the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("deleteVenue", parameterList);

                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Deletes a venue from the database.
        /// 0 returns successful delete.
        /// 1 returns failed delete.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The username is already being used and/or the administrator already exists.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="venueName"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int deleteVenueName(string venueName)
        {
            try
            {
                // Verify the venue actually exists.
                if (ValidateVenueName(venueName) == 1)
                    throw new Exception("The venue does not exist.");

                // Create parameters for stored procedure. If the parameters do not meet database criteria, 
                // throw an ArgumentException.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                if (venueName.Length > 50)
                    throw new ArgumentException("Venue name must be 50 characters or less.");
                parameter1.Value = venueName;
                parameterList.Add(parameter1);

                // Execute the stored procedure and delete the value from the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("deleteListOfVenues", parameterList);

                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        
        /* CREDIT CARD METHODS */
        /* ============================================================================================== */               
        /// <summary>
        /// Returns a _CreditCard object from the database.
        /// </summary>
        /// <param name="creditCardNumber"></param>
        /// <returns>_CreditCard</returns>
        [WebMethod]
        public _CreditCard getCreditCard(long creditCardNumber)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@CCNum", SqlDbType.VarChar);
                parameter1.Value = creditCardNumber;
                parameterList.Add(parameter1);

                // Execute the stored procedure to return a _CreditCard dataset object.
                DataConversion DC = new DataConversion();
                return DC.ConvertDataSetTo_CreditCard(
                    executeProcedure("getSingleCreditCard", parameterList));
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Inserts a _CreditCard object into the database.
        /// 0 returns successful insert.
        /// 1 returns failed insert.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The credit card is already being used.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="creditCardNumber"></param>
        /// <param name="nameOnCard"></param>
        /// <param name="cardType"></param>
        /// <param name="securityNum"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int insertCreditCard(string userName, long creditCardNumber, string nameOnCard, 
            string cardType, int securityNum)
        {
            try
            {
                // Verify the username is available before continuing any further.
                // If it is not available, throw an Exception stating there needs to be a user.
                int errorCode = ValidateUsername(userName);

                // Checks the username. If it's true, the username exists.
                if (errorCode == 1)
                    throw new Exception("The user associated with the Credit Card does not exist.");

                // There was a database error.
                if (errorCode == 2)
                    throw new InvalidOperationException("There was a database error.");

                // Validate the credit card. Make sure the number doesn't already exist in the database.
                errorCode = ValidateCreditCard(creditCardNumber);

                // Checks the credit card number. If it's true, the credit card number exists.
                if (errorCode == 0)
                    throw new Exception("The Credit Card number already exists.");

                // There was a database error.
                if (errorCode == 2)
                    throw new InvalidOperationException("There was a database error.");

                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("userName", SqlDbType.VarChar);
                if (userName.Length > 20)
                    throw new ArgumentException("The username must be 20 characters or less.");
                parameter1.Value = userName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@CCNum", SqlDbType.NChar);
                parameter2.Value = creditCardNumber;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@name", SqlDbType.VarChar);
                if (nameOnCard.Length > 40)
                    throw new ArgumentException("The name on the card must be 40 characters or less.");
                parameter3.Value = nameOnCard;
                parameterList.Add(parameter3);

                SqlParameter parameter4 = new SqlParameter("@cardType", SqlDbType.VarChar);
                if (cardType.Length > 20)
                    throw new ArgumentException("The card type must be 20 characters or less.");
                parameter4.Value = cardType;
                parameterList.Add(parameter4);

                SqlParameter parameter5 = new SqlParameter("@securityNum", SqlDbType.Int);
                if (securityNum > 999 || securityNum < 100)
                    throw new ArgumentException("The security number on the card must be 3 digits.");
                parameter5.Value = securityNum;
                parameterList.Add(parameter5);

                // Execute the stored procedure and insert the new value into the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("addCreditCard", parameterList);

                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Deletes a _CreditCard object from the database.
        /// 0 returns successful delete.
        /// 1 returns failed delete.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The credit card does not exist.
        /// </summary>
        /// <param name="creditCardNumber"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int deleteCreditCard(long creditCardNumber)
        {
            try
            {
                // Validate the credit card. Make sure the number already exists in the database.
                int errorCode = ValidateCreditCard(creditCardNumber);

                // Checks the credit card number. If it's false, the credit card number does not exist.
                if (errorCode == 1)
                    throw new Exception("The Credit Card number does not exist.");

                // There was a database error.
                if (errorCode == 2)
                    throw new InvalidOperationException("There was a database error.");

                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@CCNum", SqlDbType.NChar);
                parameter1.Value = creditCardNumber;
                parameterList.Add(parameter1);

                // Execute the stored procedure and insert the new value into the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("deleteCreditCard", parameterList);

                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }


        /* SECTION METHODS */
        /* ============================================================================================== */
        /// <summary>
        /// Returns a list of all recorded sections in the specified event.
        /// </summary>
        /// <param name="venueName"></param>
        /// <returns>List&lt;_Section&gt;</returns>
        [WebMethod]
        public List<_Section> getSectionsInVenue(string eventName, string venueName)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter2.Value = venueName;
                parameterList.Add(parameter2);

                // Execute the stored procedure and return a dataset.
                DataConversion DC = new DataConversion();
                List<_Section> sectionList = DC.ConvertDataSetTo_SectionList(
                    executeProcedure("getSectionsInVenue", parameterList));

                foreach (_Section s in sectionList)
                {
                    fillSectionFromTables(s, eventName, venueName);
                }
                return sectionList;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns a _section object specified from the database.
        /// </summary>
        /// <param name="sectionName"></param>
        /// <param name="venueName"></param>
        /// <returns>_Section</returns>
        [WebMethod]
        public _Section getSection(string eventName, string venueName, string sectionName)
        {
            try
            {
                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                parameter1.Value = sectionName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter2.Value = venueName;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter3.Value = eventName;
                parameterList.Add(parameter3);

                // Execute the stored procedure and return a dataset.
                DataConversion DC = new DataConversion();

                return fillSectionFromTables(DC.ConvertDataSetTo_Section(
                    executeProcedure("getSection", parameterList)), eventName, venueName);
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Deletes a _Section object from the database.
        /// 0 returns successful delete.
        /// 1 returns failed delete.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The section is not existent.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="venueName"></param>
        /// <param name="sectionName"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int deleteSection(string eventName, string venueName, string sectionName)
        {
            try
            {
                // Verify the section name is available before continuing any further.
                // If it is not available, throw an Exception stating there needs to be a section.
                int errorCode = ValidateSection(venueName, sectionName);

                // Checks the section name. If it's false, the section does not exist.
                if (errorCode == 1)
                    throw new Exception("The section already exists.");

                // There was a database error.
                if (errorCode == 2)
                    throw new InvalidOperationException("There was a database error.");

                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                if (venueName.Length > 50)
                    throw new ArgumentException("The venue name must be 50 characters or less.");
                parameter1.Value = venueName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                if (sectionName.Length > 50)
                    throw new ArgumentException("The section name must be 50 characters or less.");
                parameter2.Value = sectionName;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@eventName", SqlDbType.VarChar);
                if (eventName.Length > 50)
                    throw new ArgumentException("The event name must be 50 characters or less.");
                parameter3.Value = venueName;
                parameterList.Add(parameter3);

                // Execute the stored procedure and delete the value from the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("deleteSection", parameterList);

                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Inserts a _Section object into the database.
        /// 0 returns successful insert.
        /// 1 returns failed insert.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The credit card is already being used.
        /// </summary>
        /// <param name="venueName"></param>
        /// <param name="sectionName"></param>
        /// <param name="basePrice"></param>
        /// <param name="priceMultiplier"></param>
        /// <param name="multiplierFrequency"></param>
        /// <param name="sectionAvailable"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int insertSection(string venueName, string sectionName, decimal basePrice, 
            decimal priceMultiplier, int multiplierFrequency, bool sectionAvailable)
        {
            try
            {
                // Verify the section name is available before continuing any further.
                // If it is not available, throw an Exception stating there needs to be a user.
                int errorCode = ValidateSection(venueName, sectionName);

                // Checks the section name. If it's true, the section name exists.
                if (errorCode == 0)
                    throw new Exception("The section already exists.");

                // There was a database error.
                if (errorCode == 2)
                    throw new InvalidOperationException("There was a database error.");

                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                if (venueName.Length > 50)
                    throw new ArgumentException("The venue name must be 50 characters or less.");
                parameter1.Value = venueName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                if (sectionName.Length > 50)
                    throw new ArgumentException("The section name must be 50 characters or less.");
                parameter2.Value = sectionName;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@basePrice", SqlDbType.Decimal);
                parameter3.Value = basePrice;
                parameterList.Add(parameter3);

                SqlParameter parameter4 = new SqlParameter("@priceMultiplier", SqlDbType.Decimal);
                parameter4.Value = priceMultiplier;
                parameterList.Add(parameter4);

                SqlParameter parameter5 = new SqlParameter("@multiplierFrequency", SqlDbType.Int);
                parameter5.Value = multiplierFrequency;
                parameterList.Add(parameter5);

                SqlParameter parameter6 = new SqlParameter("@sectionAvailable", SqlDbType.Bit);
                parameter6.Value = sectionAvailable;
                parameterList.Add(parameter6);

                // Execute the stored procedure and insert the new value into the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("addSection", parameterList);

                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }

        /// <summary>
        /// Modifies a section from the database.
        /// 0 returns successful update.
        /// 1 returns failed update.
        /// 2 returns SqlException. There was a database error.
        /// 3 returns ArgumentException. The criteria rejected the values.
        /// 4 returns Exception. The section does not exist.
        /// </summary>
        /// <param name="venueName"></param>
        /// <param name="sectionName"></param>
        /// <param name="newSectionName"></param>
        /// <param name="basePrice"></param>
        /// <param name="priceMultiplier"></param>
        /// <param name="multiplierFrequency"></param>
        /// <param name="sectionAvailable"></param>
        /// <returns>int</returns>
        [WebMethod]
        public int updateSection(string venueName, string sectionName, string newSectionName, 
            decimal basePrice, decimal priceMultiplier, int multiplierFrequency, bool sectionAvailable)
        {
            try
            {
                // Verify the section name is available before continuing any further.
                // If it is not available, throw an Exception stating there needs to be a user.
                int errorCode = ValidateSection(venueName, sectionName);

                // Checks the section name. If it's true, the section name exists.
                if (errorCode == 1)
                    throw new Exception("The section does not exist.");

                // There was a database error.
                if (errorCode == 2)
                    throw new InvalidOperationException("There was a database error.");

                errorCode = ValidateSection(venueName, newSectionName);

                // Checks the section name. If it's true, the section name exists.
                if (errorCode == 0)
                    throw new Exception("The new section already exists.");

                // There was a database error.
                if (errorCode == 2)
                    throw new InvalidOperationException("There was a database error.");

                // Create parameters for stored procedure
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                if (venueName.Length > 50)
                    throw new ArgumentException("The venue name must be 50 characters or less.");
                parameter1.Value = venueName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                if (sectionName.Length > 50)
                    throw new ArgumentException("The section name must be 50 characters or less.");
                parameter2.Value = sectionName;
                parameterList.Add(parameter2);

                SqlParameter parameter7 = new SqlParameter("@newSectionName", SqlDbType.VarChar);
                if (newSectionName.Length > 50)
                    throw new ArgumentException("The new section name must be 50 characters or less.");
                parameter7.Value = newSectionName;
                parameterList.Add(parameter7);

                SqlParameter parameter3 = new SqlParameter("@basePrice", SqlDbType.Decimal);
                parameter3.Value = basePrice;
                parameterList.Add(parameter3);

                SqlParameter parameter4 = new SqlParameter("@priceMultiplier", SqlDbType.Decimal);
                parameter4.Value = priceMultiplier;
                parameterList.Add(parameter4);

                SqlParameter parameter5 = new SqlParameter("@multiplierFrequency", SqlDbType.Int);
                parameter5.Value = multiplierFrequency;
                parameterList.Add(parameter5);

                SqlParameter parameter6 = new SqlParameter("@sectionAvailable", SqlDbType.Bit);
                parameter6.Value = sectionAvailable;
                parameterList.Add(parameter6);

                // Execute the stored procedure and insert the new value into the database.
                // Return the row count affected to determine if there was an error.
                executeProcedure("editSection", parameterList);

                return 0;
            }
            catch (ArgumentException argumentException)
            {
                // The parameter criteria do not match the database.
                Console.WriteLine(argumentException.Message);
                return 3;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (Exception exception)
            {
                // Either the values are already used, or there was another unidentified error.
                Console.WriteLine(exception.Message);
                return 4;
            }
        }


        /* VALIDATION METHODS */
        /* ============================================================================================== */
        /// <summary>
        /// This method determines whether or not the Username is taken in the database.
        /// 0 returns "name is already taken".
        /// 1 returns "name is available".
        /// 2 returns SqlException. There was a database error.
        /// </summary>
        /// <param name="username"></param>
        /// <returns>int</returns>
        public int ValidateUsername(string username)
        {
            try
            {
                // Create the parameter list and add the parameters.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@username", SqlDbType.VarChar);
                parameter1.Value = username;
                parameterList.Add(parameter1);

                // Execute the procedure. The procedure should return values only if there is a match.
                DataSet dataSet = executeProcedure("verifyUsername", parameterList);
                DataTable dataTable = dataSet.Tables[0];

                // Check the table for the returned value.
                foreach (DataColumn column in dataTable.Columns)
                {
                    foreach (DataRow row in dataTable.Rows)
                    {
                        if (column.Caption == "username")
                            // The username is taken.
                            if (username == row[column].ToString().Trim()) return 0;
                    }
                }
                // Value is not taken.
                return 1;
            }
            catch (SqlException sqlException)
            {
                // A database error has occured.
                Console.WriteLine(sqlException.Message);
                // Return "taken" due to error.
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
        }

        /// <summary>
        /// This method determines whether or not the User is a guest account in the database.
        /// 0 returns "name is guest account".
        /// 1 returns "name is not a guest account".
        /// 2 returns SqlException. There was a database error.
        /// </summary>
        /// <param name="username"></param>
        /// <returns>int</returns>
        private int ValidateGuest(string username)
        {
            try
            {
                // Create the parameter list and add the parameters.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@username", SqlDbType.VarChar);
                parameter1.Value = username;
                parameterList.Add(parameter1);

                // Execute the procedure. The procedure should return values only if there is a match.
                DataSet dataSet = executeProcedure("verifyGuest", parameterList);
                DataTable dataTable = dataSet.Tables[0];

                // Check the table for the returned value.
                foreach (DataColumn column in dataTable.Columns)
                {
                    foreach (DataRow row in dataTable.Rows)
                    {
                        if (column.Caption == "userName")
                            // The username is a guest account.
                            if (username == row[column].ToString().Trim()) return 0;
                    }
                }
                // Value is not taken.
                return 1;
            }
            catch (SqlException sqlException)
            {
                // A database error has occured.
                Console.WriteLine(sqlException.Message);
                // Return "taken" due to error.
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
        }

        /// <summary>
        /// This method determines whether or not the credit card number is taken in the database.
        /// 0 returns "number is already taken".
        /// 1 returns "number is available".
        /// 2 returns SqlException. There was a database error.
        /// </summary>
        /// <param name="creditCardNumber"></param>
        /// <returns>int</returns>
        private int ValidateCreditCard(long creditCardNumber)
        {
            try
            {
                // Create the parameter list and add the parameters.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@CCNum", SqlDbType.NChar);
                parameter1.Value = creditCardNumber;
                parameterList.Add(parameter1);

                // Execute the procedure. The procedure should return values only if there is a match.
                DataSet dataSet = executeProcedure("verifyCreditCard", parameterList);
                DataTable dataTable = dataSet.Tables[0];

                // Check the table for the returned value.
                foreach (DataColumn column in dataTable.Columns)
                {
                    foreach (DataRow row in dataTable.Rows)
                    {
                        if (column.Caption == "CCNum")
                            // The username is taken.
                            if (creditCardNumber == Convert.ToInt64(row[column])) return 0;
                    }
                }
                // Value is not taken.
                return 1;
            }
            catch (SqlException sqlException)
            {
                // A database error has occured.
                Console.WriteLine(sqlException.Message);
                // Return "taken" due to error.
                return 2;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
        }

        /// <summary>
        /// This method determines whether or not the Username is taken in the database.
        /// 0 returns "name is already taken".
        /// 1 returns "name is available".
        /// 2 returns SqlException. There was a database error.
        /// </summary>
        /// <param name="username"></param>
        /// <returns>int</returns>
        private int ValidateAdministrator(string username)
        {
            try
            {
                // Create the parameter list and add the parameters.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@username", SqlDbType.VarChar);
                parameter1.Value = username;
                parameterList.Add(parameter1);

                // Execute the procedure. The procedure should return values only if there is a match.
                DataSet dataSet = executeProcedure("verifyAdmin", parameterList);
                DataTable dataTable = dataSet.Tables[0];

                // Check the table for the returned value.
                foreach (DataRow row in dataTable.Rows)
                {
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "userID")
                        {
                            // The user exists.
                            if (row[column] != null) return 0;
                        }
                    }
                }
                // User does not exist.
                return 1;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (SqlException sqlException)
            {
                // A database error has occured.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
        }

        /// <summary>
        /// This method determines whether or not the email is taken in the database.
        /// 0 returns "name is already taken".
        /// 1 returns "name is available".
        /// 2 returns SqlException. There was a database error.
        /// </summary>
        /// <param name="email"></param>
        /// <returns>int</returns>
        public int ValidateEmail(string email)
        {
            try
            {
                // Create the parameter list and add the parameters.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@email", SqlDbType.VarChar);
                parameter1.Value = email;
                parameterList.Add(parameter1);

                // Execute the procedure. The procedure should return values only if there is a match.
                DataSet dataSet = executeProcedure("verifyEmail", parameterList);
                DataTable dataTable = dataSet.Tables[0];

                // Check the table for the returned value.
                foreach (DataColumn column in dataTable.Columns)
                {
                    foreach (DataRow row in dataTable.Rows)
                    {
                        if (column.Caption == "email")
                            // The email is taken.
                            if (email == row[column].ToString().Trim()) return 0;
                    }
                }
                // Value is not taken.
                return 1;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (SqlException sqlException)
            {
                // A database error has occured.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
        }

        /// <summary>
        /// This method determines whether or not the venue name is taken in the database.
        /// 0 returns "name is already taken".
        /// 1 returns "name is available".
        /// 2 returns SqlException. There was a database error.
        /// </summary>
        /// <param name="venueName"></param>
        /// <param name="eventName"></param>
        /// <returns>int</returns>
        private int ValidateVenueName(string venueName)
        {
            try
            {
                // Create the parameter list and add the parameters.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter1.Value = venueName;
                parameterList.Add(parameter1);

                // Execute the procedure. The procedure should return values only if there is a match.
                DataSet dataSet = executeProcedure("verifyVenueName", parameterList);
                DataTable dataTable = dataSet.Tables[0];

                // Check the table for the returned value.
                foreach (DataColumn column in dataTable.Columns)
                {
                    foreach (DataRow row in dataTable.Rows)
                    {
                        if (column.Caption == "venueName")
                            // The venue exists.
                            if (row[column] != null) return 0;
                    }
                }
                // Value is not taken.
                return 1;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (SqlException sqlException)
            {
                // A database error has occured.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
        }

        /// <summary>
        /// This method determines whether or not the venue is taken in the database.
        /// 0 returns "name is already taken".
        /// 1 returns "name is available".
        /// 2 returns SqlException. There was a database error.
        /// </summary>
        /// <param name="venueName"></param>
        /// <param name="eventName"></param>
        /// <returns>int</returns>
        private int ValidateVenue(string venueName, string eventName)
        {
            try
            {
                // Create the parameter list and add the parameters.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter1.Value = venueName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter2.Value = eventName;
                parameterList.Add(parameter2);

                // Execute the procedure. The procedure should return values only if there is a match.
                DataSet dataSet = executeProcedure("verifyVenue", parameterList);
                DataTable dataTable = dataSet.Tables[0];

                // Check the table for the returned value.
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        foreach (DataRow row in dataTable.Rows)
                        {
                            if (column.Caption == "venueName")
                            // The venue exists.
                            if (row[column] != null) return 0;
                    }
                }
                // Value is not taken.
                return 1;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (SqlException sqlException)
            {
                // A database error has occured.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
        }

        /// <summary>
        /// This method determines whether or not the section is taken in the database associated with the 
        /// venue name.
        /// 0 returns "name is already taken".
        /// 1 returns "name is available".
        /// 2 returns SqlException. There was a database error.
        /// </summary>
        /// <param name="venueName"></param>
        /// <param name="sectionName"></param>
        /// <returns>int</returns>
        private int ValidateSection(string venueName, string sectionName)
        {
            try
            {
                // Create the parameter list and add the parameters.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter1.Value = venueName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                parameter2.Value = sectionName;
                parameterList.Add(parameter2);

                // Execute the procedure. The procedure should return values only if there is a match.
                DataSet dataSet = executeProcedure("verifySection", parameterList);
                DataTable dataTable = dataSet.Tables[0];

                // Check the table for the returned value.
                foreach (DataColumn column in dataTable.Columns)
                {
                    foreach (DataRow row in dataTable.Rows)
                    {
                        if (column.Caption == "sectionName")
                            // The venue exists.
                            if (row[column] != null) return 0;
                    }
                }
                // Value is not taken.
                return 1;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (SqlException sqlException)
            {
                // A database error has occured.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
        }

        /// <summary>
        /// This method determines whether or not the event is taken in the database.
        /// 0 returns "event is already taken".
        /// 1 returns "event is available".
        /// 2 returns SqlException. There was a database error.
        /// </summary>
        /// <param name="eventName"></param>
        /// <returns>int</returns>
        private int ValidateEvent(string eventName)
        {
            try
            {
                // Create the parameter list and add the parameters.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                // Execute the procedure. The procedure should return values only if there is a match.
                DataSet dataSet = executeProcedure("verifyEvent", parameterList);
                DataTable dataTable = dataSet.Tables[0];

                // Check the table for the returned value.
                foreach (DataColumn column in dataTable.Columns)
                {
                    foreach (DataRow row in dataTable.Rows)
                    {
                        if (column.Caption == "eventName")
                            // The venue exists.
                            if (row[column] != null) return 0;
                    }
                }
                // Value is not taken.
                return 1;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (SqlException sqlException)
            {
                // A database error has occured.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
        }

        /// <summary>
        /// This method determines whether or not the ticket is taken in the database.
        /// 0 returns "Ticket is already taken".
        /// 1 returns "Ticket is available".
        /// 2 returns SqlException. There was a database error.
        /// </summary>
        /// <param name="className"></param>
        /// <param name="eventName"></param>
        /// <param name="venueName"></param>
        /// <param name="sectionName"></param>
        /// <param name="row"></param>
        /// <param name="seat"></param>
        /// <returns>int</returns>
        private int ValidateTicket(string eventName, string venueName, string sectionName, string row, 
            string seat)
        {
            try
            {
                // Create the parameter list and add the parameters.
                List<SqlParameter> parameterList = new List<SqlParameter>();

                SqlParameter parameter2 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter2.Value = eventName;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter3.Value = venueName;
                parameterList.Add(parameter3);

                SqlParameter parameter4 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                parameter4.Value = sectionName;
                parameterList.Add(parameter4);

                SqlParameter parameter5 = new SqlParameter("@row", SqlDbType.VarChar);
                parameter5.Value = row;
                parameterList.Add(parameter5);

                SqlParameter parameter6 = new SqlParameter("@seat", SqlDbType.VarChar);
                parameter6.Value = seat;
                parameterList.Add(parameter6);

                // Execute the procedure. The procedure should return values only if there is a match.
                DataSet dataSet = executeProcedure("verifyTicket", parameterList);
                DataTable dataTable = dataSet.Tables[0];

                // Check the table for the returned value.
                foreach (DataColumn column in dataTable.Columns)
                {
                    foreach (DataRow dataRow in dataTable.Rows)
                    {
                        if (column.Caption == "ticketID")
                            // The ticket exists.
                            if (dataRow[column] != null) return 0;
                    }
                }
                // Value is not taken.
                return 1;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (SqlException sqlException)
            {
                // A database error has occured.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
        }

        /// <summary>
        /// This method determines whether or not the ticket type is taken in the database.
        /// 0 returns "Ticket type is already taken".
        /// 1 returns "Ticket type is available".
        /// 2 returns SqlException. There was a database error.
        /// </summary>
        /// <param name="className"></param>
        /// <returns>int</returns>
        private int ValidateTicketType(string className)
        {
            try
            {
                // Create the parameter list and add the parameters.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@className", SqlDbType.VarChar);
                parameter1.Value = className;
                parameterList.Add(parameter1);

                // Execute the procedure. The procedure should return values only if there is a match.
                DataSet dataSet = executeProcedure("verifyTicketType", parameterList);
                DataTable dataTable = dataSet.Tables[0];

                // Check the table for the returned value.
                foreach (DataColumn column in dataTable.Columns)
                {
                    foreach (DataRow dataRow in dataTable.Rows)
                    {
                        if (column.Caption == "className")
                            // The ticket type exists.
                            if (dataRow[column] != null) return 0;
                    }
                }
                // Value is not taken.
                return 1;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (SqlException sqlException)
            {
                // A database error has occured.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
        }   

        /// <summary>
        /// This method determines whether or not the confirmationNumber is taken in the database.
        /// 0 returns "confirmation available".
        /// 1 returns "confirmation already exists".
        /// 2 returns SqlException. There was a database error.
        /// </summary>
        /// <param name="confirmationNumber"></param>
        /// <returns>int</returns>
        private int ValidateConfirmationNumber(string confirmationNumber)
        {
            try
            {
                // Create the parameter list and add the parameters.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@confirmNum", SqlDbType.VarChar);
                parameter1.Value = confirmationNumber;
                parameterList.Add(parameter1);

                // Execute the procedure. The procedure should return values only if there is a match.
                DataSet dataSet = executeProcedure("verifyConfirmNum", parameterList);
                DataTable dataTable = dataSet.Tables[0];

                // Check the table for the returned value.
                foreach (DataColumn column in dataTable.Columns)
                {
                    foreach (DataRow row in dataTable.Rows)
                    {
                        if (column.Caption == "confirmNum")
                            // The confirmNum exists.
                            if (row[column] != null) return 0;
                    }
                }
                // Value is not taken.
                return 1;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return 1;
            }
            catch (SqlException sqlException)
            {
                // A database error has occured.
                Console.WriteLine(sqlException.Message);
                return 2;
            }
        }

        /// <summary>
        /// This method determines whether or not the email and/or username are taken in the database.
        /// 0 returns "name is already taken".
        /// 1 returns "name is available".
        /// 2 returns SqlException. There was a database error.
        /// </summary>
        /// <param name="email"></param>
        /// <param name="username"></param>
        /// <returns>List&lt;int&gt;</returns>
        private List<int> ValidateUsernameAndEmail(string email, string username)
        {
            try
            {
                // Create the parameter list and add the parameters.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                SqlParameter parameter1 = new SqlParameter("@email", SqlDbType.VarChar);
                parameter1.Value = email;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@username", SqlDbType.VarChar);
                parameter2.Value = username;
                parameterList.Add(parameter2);

                // Execute the procedure. The procedure should return values only if there is a match.
                DataSet dataSet = executeProcedure("verifyUsernameAndEmail", parameterList);

                DataTable dataTable = dataSet.Tables[0];
                List<int> list = new List<int>();

                // Check each column first
                foreach (DataColumn column in dataTable.Columns)
                {
                    // boolCount is used to determine if there is any match to the entered value. If there
                    // is, the value will increment.
                    // Restart the boolCount variable after each column.
                    int boolCount = 0;
                    foreach (DataRow row in dataTable.Rows)
                    {
                        if (column.Caption == "email")
                            if (email == row[column].ToString().Trim()) boolCount++;

                        if (column.Caption == "username")
                            if (username == row[column].ToString().Trim()) boolCount++;
                    }
                    // If there is a match send true, otherwise there is no match and send false. This will
                    // send 2 values into a list.
                    if (boolCount > 0) list.Add(0);
                    else list.Add(1);
                }
                return list;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
            catch (SqlException sqlException)
            {
                // A database error has occured.
                Console.WriteLine(sqlException.Message);
                List<int> list = new List<int>();
                list.Add(2);
                list.Add(2);
                return list;
            }
        }


        /* DATA FILL METHODS */
        /* ============================================================================================== */
        /// <summary>
        /// Returns a _Ticket object filled with the data from the foreign tables.
        /// The method fills the ticket object's event information, venue information, and section 
        /// information.
        /// </summary>
        /// <param name="TicketObject"></param>
        /// <param name="eventName"></param>
        /// <param name="venueName"></param>
        /// <param name="sectionName"></param>
        /// <returns>_Ticket</returns>
        [WebMethod]
        private _Ticket fillTicketFromTables(_Ticket TicketObject, string eventName, string venueName, 
            string sectionName)
        {
            try
            {
                // Create parameters for stored procedure
                // Execute the next stored procedure to return a dataset of sections and fill the ticket 
                // values.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                DataConversion DC = new DataConversion();

                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter2.Value = venueName;
                parameterList.Add(parameter2);

                SqlParameter parameter3 = new SqlParameter("@sectionName", SqlDbType.VarChar);
                parameter3.Value = sectionName;
                parameterList.Add(parameter3);

                // Add the section information into the ticket.
                _Section section = DC.ConvertDataSetTo_Section(
                    executeProcedure("getSection", parameterList));
                TicketObject.basePrice = section.basePrice;
                TicketObject.multiplierFrequency = section.multiplierFrequency;
                TicketObject.priceMultiplier = section.priceMultiplier;
                TicketObject.sectionAvailable = section.sectionAvailable;
                TicketObject.sectionName = section.sectionName;

                // Clear the old parameters and create new ones.
                // Execute the next stored procedure to return a dataset of venues and fill the ticket 
                // values.
                parameterList.Clear();
                parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                parameter2 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter2.Value = venueName;
                parameterList.Add(parameter2);

                // Add the venue information into the ticket.
                _Venue venue = DC.ConvertDataSetTo_Venue(executeProcedure("getVenue", parameterList));
                TicketObject.city = venue.city;
                TicketObject.dateEnd = venue.dateEnd;
                TicketObject.dateStart = venue.dateStart;
                TicketObject.state = venue.state;
                TicketObject.venueAvailable = venue.venueAvailable;
                TicketObject.venueName = venue.venueName;

                // Clear the old parameters and create new ones.
                // Execute the next stored procedure to return a dataset of events and fill the ticket 
                // values.
                parameterList.Clear();
                parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                // Add the event information into the ticket.
                _OpenEvent openEvent = DC.ConvertDataSetTo_OpenEvent(
                    executeProcedure("getEvent", parameterList));
                TicketObject.eventAvailable = openEvent.eventAvailable;
                TicketObject.eventName = openEvent.eventName;

                return TicketObject;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns a _Section object filled with the data from the foreign tables.
        /// The method fills the section object's event information and venue information.
        /// </summary>
        /// <param name="SectionObject"></param>
        /// <param name="eventName"></param>
        /// <param name="venueName"></param>
        /// <returns>_Section</returns>
        [WebMethod]
        private _Section fillSectionFromTables(_Section SectionObject, string eventName, string venueName)
        {
            try
            {
                // Create parameters for stored procedure
                // Execute the stored procedure to return a dataset of venues and fill the section values.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                DataConversion DC = new DataConversion();

                // Execute the stored procedure to return a dataset of venues and fill the section values.
                parameterList.Clear();
                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                SqlParameter parameter2 = new SqlParameter("@venueName", SqlDbType.VarChar);
                parameter2.Value = venueName;
                parameterList.Add(parameter2);

                // Add the venue information into the section.
                _Venue venue = DC.ConvertDataSetTo_Venue(executeProcedure("getVenue", parameterList));
                SectionObject.city = venue.city;
                SectionObject.dateEnd = venue.dateEnd;
                SectionObject.dateStart = venue.dateStart;
                SectionObject.state = venue.state;
                SectionObject.venueAvailable = venue.venueAvailable;
                SectionObject.venueName = venue.venueName;

                // Clear the old parameters and create new ones.
                // Execute the next stored procedure to return a dataset of events and fill the ticket 
                // values.
                parameterList.Clear();
                parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                // Add the event information into the section.
                _OpenEvent openEvent = DC.ConvertDataSetTo_OpenEvent(
                    executeProcedure("getEvent", parameterList));
                SectionObject.eventAvailable = openEvent.eventAvailable;
                SectionObject.eventName = openEvent.eventName;

                return SectionObject;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Returns a _Venue object filled with the data from the foreign tables.
        /// The method fills the venue object's event information.
        /// </summary>
        /// <param name="VenueObject"></param>
        /// <param name="eventName"></param>
        /// <returns>_Venue</returns>
        [WebMethod]
        private _Venue fillVenueFromTables(_Venue VenueObject, string eventName)
        {
            try
            {
                // Create parameters for stored procedure
                // Execute the stored procedure to return a dataset of events and fill the venue values.
                List<SqlParameter> parameterList = new List<SqlParameter>();
                DataConversion DC = new DataConversion();

                SqlParameter parameter1 = new SqlParameter("@eventName", SqlDbType.VarChar);
                parameter1.Value = eventName;
                parameterList.Add(parameter1);

                // Add the event information into the venue.
                _OpenEvent openEvent = DC.ConvertDataSetTo_OpenEvent(
                    executeProcedure("getEvent", parameterList));
                VenueObject.eventAvailable = openEvent.eventAvailable;
                VenueObject.eventName = openEvent.eventName;

                return VenueObject;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /* STORED PROCEDURE EXECUTION METHODS */
        /* ============================================================================================== */        
        /// <summary>
        /// Executes a Stored Procedure by passing a procedure name and the parameters as a list.
        /// </summary>
        /// <param name="procedure"></param>
        /// <param name="parameters"></param>
        /// <returns>DataSet</returns>
        private DataSet executeProcedure(string procedure, List<SqlParameter> parameters)
        {
            try
            {
                // Gather the connection string settings from the Web Config.
                System.Configuration.Configuration rootWebConfig = 
                    System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/");

                // If connection string settings exist, extract the connection string and continue with the
                // execution of the procedure.
                if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0)
                {
                    System.Configuration.ConnectionStringSettings connectionStringSettings = 
                        rootWebConfig.ConnectionStrings.ConnectionStrings["ApplicationServices"];

                    // Create a new sql connection.
                    using (SqlConnection connection = 
                        new SqlConnection(connectionStringSettings.ConnectionString))
                    using (SqlCommand command = new SqlCommand(procedure, connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        // Add the transaction parameters
                        foreach (SqlParameter sp in parameters)
                        {
                            command.Parameters.Add(sp);
                        }

                        using (connection)
                        {
                            SqlDataAdapter adapter = new SqlDataAdapter();
                            adapter.SelectCommand = command;
                            DataSet dataSet = new DataSet();
                            adapter.Fill(dataSet);
                            connection.Close();
                            command.Parameters.Clear();
                            command.Dispose();
                            return dataSet;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("There are no connection strings.");
                    return null;
                }
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (ArgumentException argumentException)
            {
                // There was an argument error. (Usually caused by redundant parameters).
                Console.WriteLine(argumentException.Message);
                return null;
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
        }

        /// <summary>
        /// Executes a Stored Procedure by passing a procedure name.
        /// </summary>
        /// <param name="procedure"></param>
        /// <returns>DataSet</returns>
        private DataSet executeProcedure(string procedure)
        {
            try
            {
                // Gather the connection string settings from the Web Config.
                System.Configuration.Configuration rootWebConfig = 
                    System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/");

                // If connection string settings exist, extract the connection string and continue with 
                // the execution of the procedure.
                if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0)
                {
                    System.Configuration.ConnectionStringSettings connectionStringSettings = 
                        rootWebConfig.ConnectionStrings.ConnectionStrings["ApplicationServices"];

                    // Create a new sql connection.
                    using (SqlConnection connection = 
                        new SqlConnection(connectionStringSettings.ConnectionString))
                    using (SqlCommand command = new SqlCommand(procedure, connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        using (connection)
                        {
                            SqlDataAdapter adapter = new SqlDataAdapter();
                            adapter.SelectCommand = command;
                            DataSet dataSet = new DataSet();
                            adapter.Fill(dataSet);
                            connection.Close();
                            return dataSet;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("There are no connection strings.");
                    return null;
                }
            }
            catch (NullReferenceException nullReferenceException)
            {
                // There was a database error.
                Console.WriteLine(nullReferenceException.Message);
                return null;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
            catch (ArgumentException argumentException)
            {
                // There was an argument error. (Usually caused by redundant parameters).
                Console.WriteLine(argumentException.Message);
                return null;
            }
        }
    }


    /* INTERNAL CLASSES */
    /* ============================================================================================== */
    /// <summary>
    /// Used for Data Conversion to convert DataSets into corresponding objects.
    /// </summary>
    public class DataConversion
    {
        /// <summary>
        /// Converts a DataSet object into a _User object with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>_User</returns>
        public _User ConvertDataSetTo_User(DataSet dataSet)
        {
            try
            {
                DataTable dataTable = dataSet.Tables[0];
                _User user = new _User();
                _Address address = new _Address();
                foreach (DataRow row in dataTable.Rows)
                {
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "firstName")
                            user.firstName = row[column].ToString().Trim();
                        if (column.Caption == "lastName")
                            user.lastName = row[column].ToString().Trim();
                        if (column.Caption == "email")
                            user.email = row[column].ToString().Trim();
                        if (column.Caption == "newsLetter")
                            user.newsLetter = (bool)row[column];
                        if (column.Caption == "membershipDate")
                            user.membershipDate = (DateTime)row[column];
                        if (column.Caption == "userName")
                            user.userName = row[column].ToString().Trim();
                        if (column.Caption == "age")
                            user.age = (int)row[column];
                        if (column.Caption == "memberStatus")
                            user.memberstatus = (bool)row[column];
                        if (column.Caption == "address")
                            address.address1 = row[column].ToString().Trim();
                        if (column.Caption == "address2")
                            address.address2 = row[column].ToString().Trim();
                        if (column.Caption == "city")
                            address.city = row[column].ToString().Trim();
                        if (column.Caption == "state")
                            address.state = row[column].ToString().Trim();
                        if (column.Caption == "zip")
                            address.zip = row[column].ToString().Trim();
                        if (column.Caption == "studentStatus")
                            user.studentStatus = (bool)row[column];
                    }
                }
                user.address = address;
                return user;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a List of _User objects with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>List&lt;_User&gt;</returns>
        public List<_User> ConvertDataSetTo_UserList(DataSet dataSet)
        {
            try
            {
                List<_User> list = new List<_User>();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    _User tempUser = new _User();
                    _Address address = new _Address();
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "firstName")
                            tempUser.firstName = row[column].ToString().Trim();
                        if (column.Caption == "lastName")
                            tempUser.lastName = row[column].ToString().Trim();
                        if (column.Caption == "email")
                            tempUser.email = row[column].ToString().Trim();
                        if (column.Caption == "newsLetter")
                            tempUser.newsLetter = (bool)row[column];
                        if (column.Caption == "membershipDate")
                            tempUser.membershipDate = (DateTime)row[column];
                        if (column.Caption == "userName")
                            tempUser.userName = row[column].ToString().Trim();
                        if (column.Caption == "age")
                            tempUser.age = (int)row[column];
                        if (column.Caption == "memberStatus")
                            tempUser.memberstatus = (bool)row[column];
                        if (column.Caption == "address")
                            address.address1 = row[column].ToString().Trim();
                        if (column.Caption == "address2")
                            address.address2 = row[column].ToString().Trim();
                        if (column.Caption == "city")
                            address.city = row[column].ToString().Trim();
                        if (column.Caption == "state")
                            address.state = row[column].ToString().Trim();
                        if (column.Caption == "zip")
                            address.zip = row[column].ToString().Trim();
                        if (column.Caption == "studentStatus")
                            tempUser.studentStatus = (bool)row[column];
                    }
                    tempUser.address = address;
                    list.Add(tempUser);
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a List of string objects with filled values. This method is used
        /// to extract ticket
        /// information for the transaction object.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>List&lt;string&gt;</returns>
        public List<string> ConvertDataSetTo_stringList(DataSet dataSet)
        {
            try
            {
                List<string> list = new List<string>();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    string str = "";
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "className")
                            str = row[column].ToString().Trim();
                    }
                    list.Add(str);
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a string with filled values reflecting the session from the 
        /// database.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>string</returns>
        public string ConvertDataSetTo_SessionString(DataSet dataSet)
        {
            try
            {
                string str = "";
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "sessionID")
                            str = row[column].ToString().Trim();
                    }
                }
                return str;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into an _Administrator object with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>_Administrator</returns>
        public _Administrator ConvertDataSetTo_Administrator(DataSet dataSet)
        {
            try
            {
                DataTable dataTable = dataSet.Tables[0];
                _Administrator administrator = new _Administrator();
                _Address address = new _Address();
                foreach (DataRow row in dataTable.Rows)
                {
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "firstName")
                            administrator.firstName = row[column].ToString().Trim();
                        if (column.Caption == "lastName")
                            administrator.lastName = row[column].ToString().Trim();
                        if (column.Caption == "email")
                            administrator.email = row[column].ToString().Trim();
                        if (column.Caption == "newsLetter")
                            administrator.newsLetter = (bool)row[column];
                        if (column.Caption == "membershipDate")
                            administrator.membershipDate = (DateTime)row[column];
                        if (column.Caption == "userName")
                            administrator.userName = row[column].ToString().Trim();
                        if (column.Caption == "age")
                            administrator.age = (int)row[column];
                        if (column.Caption == "memberStatus")
                            administrator.memberstatus = (bool)row[column];
                        if (column.Caption == "address")
                            address.address1 = row[column].ToString().Trim();
                        if (column.Caption == "address2")
                            address.address2 = row[column].ToString().Trim();
                        if (column.Caption == "city")
                            address.city = row[column].ToString().Trim();
                        if (column.Caption == "state")
                            address.state = row[column].ToString().Trim();
                        if (column.Caption == "zip")
                            address.zip = row[column].ToString().Trim();
                        if (column.Caption == "studentStatus")
                            administrator.studentStatus = (bool)row[column];
                    }
                }
                administrator.address = address;
                return administrator;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a _OpenEvent object with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>_OpenEvent</returns>
        public _OpenEvent ConvertDataSetTo_OpenEvent(DataSet dataSet)
        {
            try
            {
                DataTable dataTable = dataSet.Tables[0];
                _OpenEvent openEvent = new _OpenEvent();
                foreach (DataRow row in dataTable.Rows)
                {
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "eventName")
                            openEvent.eventName = row[column].ToString().Trim();
                        if (column.Caption == "eventAvailable")
                            openEvent.eventAvailable = (bool)row[column];
                    }
                }
                return openEvent;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a _Venue object with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>_Venue</returns>
        public _Venue ConvertDataSetTo_Venue(DataSet dataSet)
        {
            try
            {
                _Venue venue = new _Venue();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "venueName")
                            venue.venueName = row[column].ToString().Trim();
                        if (column.Caption == "dateStart")
                            venue.dateStart = (DateTime)row[column];
                        if (column.Caption == "dateEnd")
                            venue.dateEnd = (DateTime)row[column];
                        if (column.Caption == "venueAvailable")
                            venue.venueAvailable = (bool)row[column];
                        if (column.Caption == "city")
                            venue.city = row[column].ToString().Trim();
                        if (column.Caption == "state")
                            venue.state = row[column].ToString().Trim();
                    }
                }
                return venue;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a _Transaction object with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>_Transaction</returns>
        public _Transaction ConvertDataSetTo_Transaction(DataSet dataSet)
        {
            try
            {
                _Transaction transaction = new _Transaction();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "confirmNum")
                            transaction.confirmationNum = row[column].ToString().Trim();
                        if (column.Caption == "purchaseDate")
                            transaction.purchaseDate = (DateTime)row[column];
                        if (column.Caption == "delivered")
                            transaction.delivered = (bool)row[column];
                    }
                }
                return transaction;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a _CreditCard object with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>_CreditCard</returns>
        public _CreditCard ConvertDataSetTo_CreditCard(DataSet dataSet)
        {
            try
            {
                _CreditCard creditCard = new _CreditCard();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "CCNum")
                            creditCard.CCNum = Convert.ToInt64(row[column]);
                        if (column.Caption == "securityNum")
                            creditCard.securityNum = Convert.ToInt32(row[column]);
                        if (column.Caption == "name")
                            creditCard.name = row[column].ToString().Trim();
                        if (column.Caption == "cardType")
                            creditCard.cardType = row[column].ToString().Trim();
                    }
                }
                return creditCard;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a list of _OpenEvent object with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>List&lt;_OpenEvent&gt;</returns>
        public List<_OpenEvent> ConvertDataSetTo_OpenEventList(DataSet dataSet)
        {
            try
            {
                List<_OpenEvent> list = new List<_OpenEvent>();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    _OpenEvent openEvent = new _OpenEvent();
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "eventName")
                            openEvent.eventName = row[column].ToString().Trim();
                        if (column.Caption == "eventAvailable")
                            openEvent.eventAvailable = (bool)row[column];
                    }
                    list.Add(openEvent);
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a _Section object with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>_Section</returns>
        public _Section ConvertDataSetTo_Section(DataSet dataSet)
        {
            try
            {
                _Section section = new _Section();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "sectionName")
                            section.sectionName = row[column].ToString().Trim();
                        if (column.Caption == "basePrice")
                            section.basePrice = (decimal)row[column];
                        if (column.Caption == "priceMultiplier")
                            section.priceMultiplier = (decimal)row[column];
                        if (column.Caption == "multiplierFrequency")
                            section.multiplierFrequency = (int)row[column];
                        if (column.Caption == "sectionAvailable")
                            section.sectionAvailable = (bool)row[column];
                    }
               }
                return section;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a list of _Section object with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>List&lt;_Section&gt;</returns>
        public List<_Section> ConvertDataSetTo_SectionList(DataSet dataSet)
        {
            try
            {
                List<_Section> list = new List<_Section>();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    _Section section = new _Section();
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "sectionName")
                            section.sectionName = row[column].ToString().Trim();
                        if (column.Caption == "basePrice")
                            section.basePrice = (decimal)row[column];
                        if (column.Caption == "priceMultiplier")
                            section.priceMultiplier = (decimal)row[column];
                        if (column.Caption == "multiplierFrequency")
                            section.multiplierFrequency = (int)row[column];
                        if (column.Caption == "sectionAvailable")
                            section.sectionAvailable = (bool)row[column];
                    }
                    list.Add(section);
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object _Ticket object with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>_Ticket</returns>
        public _Ticket ConvertDataSetTo_Ticket(DataSet dataSet)
        {
            try
            {
                _Ticket ticket = new _Ticket();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "className")
                        {
                            _TicketClass ticketType = new _TicketClass();
                            ticketType.ticketType = row[column].ToString().Trim();
                            ticket.className = ticketType;
                        }
                        if (column.Caption == "row")
                            ticket.row = row[column].ToString().Trim();
                        if (column.Caption == "seat")
                            ticket.seat = row[column].ToString().Trim();
                        if (column.Caption == "ticketAvailable")
                            ticket.ticketAvailable = (bool)row[column];
                        if (column.Caption == "price")
                            ticket.price = (decimal)row[column];
                    }
                }
                return ticket;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a List&lt;_Transaction&gt; object with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>List&lt;_Transaction&gt;</returns>
        public List<_Transaction> ConvertDataSetTo_TransactionList(DataSet dataSet)
        {
            try
            {
                List<_Transaction> list = new List<_Transaction>();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    _Transaction transaction = new _Transaction();
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "confirmNum")
                            transaction.confirmationNum = row[column].ToString().Trim();
                        if (column.Caption == "purchaseDate")
                            transaction.purchaseDate = (DateTime)row[column];
                        if (column.Caption == "delivered")
                            transaction.delivered = (bool)row[column];
                    }
                    list.Add(transaction);
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a List&lt;_Ticket&gt; object with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>List&lt;_Ticket&gt;</returns>
        public List<_Ticket> ConvertDataSetTo_TicketList(DataSet dataSet)
        {
            try
            {
                List<_Ticket> list = new List<_Ticket>();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    _Ticket ticket = new _Ticket();
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "className")
                        {
                            _TicketClass ticketType = new _TicketClass();
                            ticketType.ticketType = row[column].ToString().Trim();
                            ticket.className = ticketType;
                        }
                        if (column.Caption == "row")
                            ticket.row = row[column].ToString().Trim();
                        if (column.Caption == "seat")
                            ticket.seat = row[column].ToString().Trim();
                        if (column.Caption == "ticketAvailable")
                            ticket.ticketAvailable = (bool)row[column];
                        if (column.Caption == "price")
                            ticket.price = (decimal)row[column];
                    }
                    list.Add(ticket);
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a List&lt;_Ticket&gt; object with filled values.
        /// This method is used to get ticket details from purchased tickets and transactions.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>List&lt;_Ticket&gt;</returns>
        public List<_Ticket> ConvertDataSetTo_TicketListWithValues(DataSet dataSet)
        {
            try
            {
                List<_Ticket> list = new List<_Ticket>();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    _Ticket ticket = new _Ticket();
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "className")
                        {
                            _TicketClass ticketType = new _TicketClass();
                            ticketType.ticketType = row[column].ToString().Trim();
                            ticket.className = ticketType;
                        }
                        if (column.Caption == "eventName")
                            ticket.eventName = row[column].ToString().Trim();
                        if (column.Caption == "venueName")
                            ticket.venueName = row[column].ToString().Trim();
                        if (column.Caption == "sectionName")
                            ticket.sectionName = row[column].ToString().Trim();
                        if (column.Caption == "row")
                            ticket.row = row[column].ToString().Trim();
                        if (column.Caption == "seat")
                            ticket.seat = row[column].ToString().Trim();
                        if (column.Caption == "ticketAvailable")
                            ticket.ticketAvailable = (bool)row[column];
                        if (column.Caption == "price")
                            ticket.price = (decimal)row[column];
                    }
                    list.Add(ticket);
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a List&lt;_CreditCard&gt; object with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>List&lt;_CreditCard&gt;</returns>
        public List<_CreditCard> ConvertDataSetTo_CreditCardList(DataSet dataSet)
        {
            try
            {
                List<_CreditCard> list = new List<_CreditCard>();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    _CreditCard creditCard = new _CreditCard();
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "CCNum")
                            creditCard.CCNum = Convert.ToInt64(row[column]);
                        if (column.Caption == "securityNum")
                            creditCard.securityNum = Convert.ToInt32(row[column]);
                        if (column.Caption == "name")
                            creditCard.name = row[column].ToString().Trim();
                        if (column.Caption == "cardType")
                            creditCard.cardType = row[column].ToString().Trim();
                    }
                    list.Add(creditCard);
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a List&lt;_Venue&gt; object with filled values.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>List&lt;_Venue&gt;</returns>
        public List<_Venue> ConvertDataSetTo_VenueList(DataSet dataSet)
        {
            try
            {
                List<_Venue> list = new List<_Venue>();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    _Venue venue = new _Venue();
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "venueName")
                            venue.venueName = row[column].ToString().Trim();
                        if (column.Caption == "dateStart")
                            venue.dateStart = (DateTime)row[column];
                        if (column.Caption == "dateEnd")
                            venue.dateEnd = (DateTime)row[column];
                        if (column.Caption == "venueAvailable")
                            venue.venueAvailable = (bool)row[column];
                        if (column.Caption == "city")
                            venue.city = row[column].ToString().Trim();
                        if (column.Caption == "state")
                            venue.state = row[column].ToString().Trim();
                    }
                    list.Add(venue);
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }

        /// <summary>
        /// Converts a DataSet object into a List&lt;_Venue&gt; object with filled values.
        /// This method is used to retrieve event information from getAllVenues.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>List&lt;_Venue&gt;</returns>
        public List<_Venue> ConvertDataSetTo_VenueListWithValues(DataSet dataSet)
        {
            try
            {
                List<_Venue> list = new List<_Venue>();
                DataTable dataTable = dataSet.Tables[0];
                foreach (DataRow row in dataTable.Rows)
                {
                    _Venue venue = new _Venue();
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        if (column.Caption == "eventName")
                            venue.eventName = row[column].ToString().Trim();
                        if (column.Caption == "venueName")
                            venue.venueName = row[column].ToString().Trim();
                        if (column.Caption == "dateStart")
                            venue.dateStart = (DateTime)row[column];
                        if (column.Caption == "dateEnd")
                            venue.dateEnd = (DateTime)row[column];
                        if (column.Caption == "venueAvailable")
                            venue.venueAvailable = (bool)row[column];
                        if (column.Caption == "city")
                            venue.city = row[column].ToString().Trim();
                        if (column.Caption == "state")
                            venue.state = row[column].ToString().Trim();
                    }
                    list.Add(venue);
                }
                return list;
            }
            catch (SqlException sqlException)
            {
                // There was a database error.
                Console.WriteLine(sqlException.Message);
                return null;
            }
        }
    }
}